Fixed: AV SynEdit in a dynamically loaded DLL (not package)

Bug reports concerning HxD.
Post Reply
Tim Knipe
Posts: 2
Joined: 02 Feb 2006 02:11

Fixed: AV SynEdit in a dynamically loaded DLL (not package)

Post by Tim Knipe »

I have a DLL that uses both SynEdit and TNT components statically linked. I am loading it from a Delphi app that also uses TNT components.

The error occurs in the SysUnicode.pas unit, IsCharMsgAlreadyUnicode function. It seems that the way UniSynEdit checks if char messages are already Unicode doesn't work in a DLL.

Given that the result of the function is False if not csDesigning:

Code: Select all

      Result := CharMsgIsUnicode and (csDesigning in ComponentState);
You can move the csDesigning check to before you create the message checking control like this:

Code: Select all

  if (csDesigning in Application.ComponentState) then
  begin
    {$IFNDEF SYN_COMPILER_9_UP}
    with TUnicodeControl.Create(Application) do
    try
      ParentWindow := Application.Handle;
      // post a WideChar that cannot be converted to an AnsiChar
      PostMessageW(Handle, WM_CHAR, WideCharTestValue, 0);
      Application.ProcessMessages;
      Result := CharMsgIsUnicode and (csDesigning in ComponentState);
    finally
      Free
    end;
    {$ELSE}
    Result := True;
    {$ENDIF}
  end
  else
    Result := True;
That makes it work here at least.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Post by Maël »

Please, next time, use the bug tracker on sourceforge.net, like I wrote under "Reporting Bugs" on the page http://mh-nexus.de/unisynedit.htm .

Your proposal of using

Code: Select all

if (csDesigning in Application.ComponentState) then
would disable the "Unicode-check" at run-time, which is okay when you use TNT (as it already sets a Unicode hook) but not when you don't.

I have cleaned up the logic of my code a bit (csDesigning wasn't used correctly). Please try and replace the files on your hd with the files in this zip:
http://mh-nexus.de/downloads/SynUnicode.zip
and tell me if it fixes your problem.

If not, could you give me a simple example project with a dll and a main app that causes this problem? Thanks.
Tim Knipe
Posts: 2
Joined: 02 Feb 2006 02:11

Post by Tim Knipe »

Sorry about not going through the bug tracker.

I tried that patch and it didn't help. I have produce a test project that exhibits the problem and will email it to you.

In creating this project I have discovered that TNT is not the issue. If the loaded DLL just uses TNT there is no problem. If it uses Unicode SynEdit then it fails.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Post by Maël »

Thanks for the project, I will look at it when I have time again, i.e. in about two weeks.
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Post by Maël »

I sent you an e-mail and pointed out a link were to download the fix.
Did you try it and did you get my mail?
Maël
Site Admin
Posts: 1455
Joined: 12 Mar 2005 14:15

Post by Maël »

Fixed.
Post Reply