You are not logged in.
In MS Windows 10, a win32 mormot app compiled with Delphi XE. The following displays the contents of a TOrm class (TStatus) in a DrawGrid, using the TOrmTabletoGrid class (table is a local TOrmTable variable):
if ConnectToServer then
begin
status := TStatus.CreateAndFillPrepare(Client.Orm, '');
try
table := status.FillTable;
table.OwnerMustFree := false;
OrmTableToGrid := TOrmTableToGrid.Create(DrawGrid1, status.FillTable, Client);
OrmTableToGrid.OnHintText := OnHintText;
finally
status.Free
end
end
ctrl-click displays hint strings polluted with erroneous characters, like Chinese, rectangles etc. However the debug of OnHintText event handler shows that the Text output variable contains the correct string values:
function TMainForm.OnHintText(Sender: TOrmTable; FieldIndex, RowIndex: Integer;
var Text: string): boolean;
begin
Text := (Sender as TOrmTable).GetString(RowIndex,FieldIndex);
Result := true
end;
Any help is welcome.
Offline
I found the problem's cause in mormot.ui.core unit, in procedure DrawTextUtf8. Utf8DecodeToUnicode doesn't seem to work properly. Below is the modified version which works in my system (the original code is commented out):
procedure DrawTextUtf8(Control: TCustomControl; Canvas: TCanvas;
const Text: RawUtf8; var Rect: TRect; CalcOnly: boolean);
var
// tmp: TSynTempBuffer;
s: string;
begin
// Utf8DecodeToUnicode(Text, tmp);
s := Utf8ToString(Text);
DrawText(Canvas.Handle, PWideChar(s), length(s), Rect,
DrawTextFlags(Control, CalcOnly));
// DrawText(Canvas.Handle, tmp.buf, tmp.len shr 1, Rect,
// DrawTextFlags(Control, CalcOnly));
// tmp.Done;
end;
Offline
You are right.
It should be fixed by https://github.com/synopse/mORMot2/commit/57c91dab
The UTF-16 buffer length was incorrect, so too many random chars were displayed.
I am sorry for the bug, but the UI part of mORMot 2 is less tested than the non-UI/server part, because we mostly use it for server work yet.
And it is almost impossible to unit-test some UI code.
These UI units were directly converted from mORMot 1, and certainly some bugs did appear within the conversion.
Don't hesitate to come back here and report any problem.
Thanks a lot for having taken the time to debug and find the root cause.
Offline
You're welcome, thank you @ab (and the rest of the mormot contributors) for your outstanding work!
Offline