[Solved] ImageListEditor problem lazarus / 9-Editor ---------------------------------------------------------------------- Bart · 2011-11-10 17:38 Hi, I have a mysterious problem with my Lazarus. When I open the ImageListEditor the ImageListEditor opens with the Imagelist. So far so good. The ImageListEditor shows up with the correct images from the ImageList. Now, whenI click on Add.. nothing happens (a TOpenPictureFileDialog is supposed to open here). This happened to me in r33269, when some days ago the same revision worked perfectly. I started Lazarus with a clean profile: no luck. I rebuild Lazarus (clean + all): no luck. I updated to r33459 and rebuilt (make clean all): no luck. The bizarre part is that when I write a test program invoking the ImageListEditor: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var   ImageListEditorDlg: TImageListEditorDlg; begin     ImageListEditorDlg := TImageListEditorDlg.Create(Application);     try       ImageListEditorDlg.LoadFromImageList(ImageList1);       if ImageListEditorDlg.ShowModal = mrOk then         ImageListEditorDlg.SaveToImageList;     finally       ImageListEditorDlg.Free;     end; end; This works perfectly: the ImageListEditor shows with the correct images, and clicking the Add button shows a PictureOpenDialog, and I can add pictures and they are saved in teh ImageList. I then added some debugstatements to Code: [Select]procedure TImageListEditorDlg.BtnAddClick(Sender: TObject); var   I: Integer; begin   if OpenDialog.Execute then   begin     TreeView.BeginUpdate; [snip] And this showed me that OpenDialog.Execute returned False. I then copied the lazarus.exe to another computer (where I first updated to same revision and rebuild), and the ImageListEditor (in the copied lazarus.exe) worked just fine. I also copied the original lazarus.exe (built there) from the other computer to mine, and the problem persists. Does anyone have an idea? Bart ---------------------------------------------------------------------- Blaazen · 2011-11-10 17:58 I have no such problems in r.33460 with Linux+Qt. Maybe it is platform specific issue ? ---------------------------------------------------------------------- Bart · 2011-11-10 18:15 It may even be a problem with my computer. The machine in question is a 11 year old Celeron system with WinME as OS. I have otherwise not experienced problems with any other applications on this machine though. The other computer (where all is fine) is a recent laptop with Win7. It is really baffling me. Bart ---------------------------------------------------------------------- Bart · 2011-11-11 11:50 Well, it is not my computer per se. I narrowed it down to recent changes in paswstring.pas (A part of LazUtils that  sets the widestringmanager for Lazarus). All is fine up to r32966 The next revisions, r32967, r32972 (revisions of paswstring.pas) crash Lazarus on startup. In r32975 of paswstring.pas (which fixes the crash) the described bug can be seen. Now if I also use paswstring in my test project, the same error occurs. Actually OpenPictureDialog.Execute does not show the dialog anymore. Here's some test code using the widestringmanager: Code: [Select]procedure TForm1.Button2Click(Sender: TObject); var   S, S2: String;   W, W2: WideString; begin   S := 'abc';   S2 := Utf8UpperCase(S);   W := 'xyz';   W2 := WideUppercase(W);   debugln('Utf8UpperCase(',S,') = ',S2);   debugln('WideUppercase(',W,') = ',W2); end;  Output without using unit paswsrting (but with win9xwsmanager unit): Code: [Select]Utf8UpperCase(abc) = ABC WideUppercase(xyz) = XYZ Output with use of paswstring unit (with or without win9xwsmanager) Note I clicked the button twice this time, because of first result. Code: [Select]Utf8UpperCase(abc) = ABC WideUppercase(x+¦ ) = X+Ö  // x+¦  (on the left side) should be xyz Utf8UpperCase(abc) = ABC WideUppercase(xyZ) = XYZ   // xyZ  (on the left side) should be xyz (note the capital Z) Bart ---------------------------------------------------------------------- Bart · 2011-11-11 12:09 With r32978 (latest change in paswstring.pas) the reults are Code: [Select]Utf8UpperCase(abc) = ABC WideUppercase(x ) = X Utf8UpperCase(abc) = ABC WideUppercase(xyZ) = XYZ Bart ---------------------------------------------------------------------- Bart · 2011-11-11 12:20 The horror starts right here! Code: [Select]procedure TForm1.NormalBtnClick(Sender: TObject); var   S: String;   W: WideString; begin   S := 'abc';   W := 'xyz';   debugln('S = ',S);   debugln('W = ',W); end; Output: Code: [Select]S = abc W = xyC Bart ---------------------------------------------------------------------- Bart · 2011-11-11 20:12 The problem is the wong implementation of Wide2AnsiMove() Code: [Select]procedure Wide2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt); var   widestr: widestring; begin   {$ifdef PASWSTRING_VERBOSE}WriteLn('Wide2AnsiMove START');{$endif}   // Copy the originating string taking into account the specified length   SetLength(widestr, len);   System.Move(source^, widestr[1], len); This should be replaced by   System.Move(source^, widestr[1], len * SizeOf(WChar)); I created a bugreport and attached a patch in http://bugs.freepascal.org/view.php?id=20668 Bart