Following code crashes application lazarus / 31-LCL ---------------------------------------------------------------------- ertank · 2018-04-23 10:13 Hello, I am using Code: [Select]fpc 3.1.1/trunk svn revision 38804 2018-04-22 lazarus 1.9.0/trunk svn revision 57163 2018-01-27 Target is arm-wince executable. Having just two forms in the project. Following code crashes application. First screen task bar starts to flicker. After several seconds message displayed as "application project1.exe encountered a serious error and must shut down." Code: [Select]uses   Unit2; { TForm1 } procedure Log(const Value: string); var   FileName: string;   F: TextFile;   Prefix: string; begin   FileName := ExtractFilePath(Application.ExeName) + FormatDateTime('yyyy-mm', Now()) + '.log';   AssignFile(F, FileName);   {$I-}   if FileExists(FileName) then Append(F) else ReWrite(F);   if IOResult <> 0 then Exit();   Prefix := FormatDateTime('yyyy-mm-dd hh:nn:ss   ', Now());   WriteLn(F, Prefix + Value);   CloseFile(F);   {$I+} end; procedure TForm1.FormCreate(Sender: TObject); begin   Top := 20;   Left := 20; end; procedure TForm1.Button1Click(Sender: TObject); var   Form: TForm2; begin   Log('1');   Form := TForm2.Create(Self);   try     Log('2');     Self.Hide();     Log('3');     Form.ShowModal();     Log('4');   finally     Form.Free();   end; end; In log file, I read 1, 2, 3 written. There is no 4. Same error displayed if I try to display Form2 window using "Form.Show()" instead of "Form.ShowModal". Sample project to reproduce can be found attached. Any help is appreciated. Edit: Here is a video for understanding the problem. In the video, I did not hide Form1 in order to "feel" how Form2 behaves. http://s3.dosya.tc/server15/ttfrxy/VID_20180423_134040.mp4.html ---------------------------------------------------------------------- WooBean · 2018-04-23 11:15 @ertank Hi, just modify your procedure TForm1.Button1Click(Sender: TObject) as below: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TForm1.Button1Click(Sender: TObject);var  Form: TForm2;begin  Log('1');  Form := TForm2.Create(Self);  Form.visible := False; //for modal usage a form must be non-visible at first  try    Log('2');    Self.Hide();    Log('3');    Form.ShowModal();    Log('4');  finally  Form.Free();    Self.Show(); //just to have something visible  end;end;  WooBean ---------------------------------------------------------------------- ertank · 2018-04-23 11:25 Hello WooBean, Same error displays using your code. Most likely this is something else. If you can watch video link I provided, you will see that same error is displayed even if I use Show and not use any "modal". (Behavior is slightly visible if I use Show) I suspect, Top and Left properties of the Form2 is changing (reducing) so much that it is out of bounds of Integer and that kills the application. I have no idea why this happens though? Wild and non- educated guess: Anything to do with PPI (aka DPI)? Thanks. ---------------------------------------------------------------------- WooBean · 2018-04-23 12:29 @ertank Once again. I tested your code but in different environment: Laz. 1.8.0, FPC 3.0.4, win32, LCL widgetset, optimization level=0 and enabled debug info. It works for me. My amendments are not needed as  its goal was achived in unit2. Problem is not in the application but is widgetset specific. WooBean ---------------------------------------------------------------------- ertank · 2018-04-23 13:30 Hello WooBean, Would you advise if Lazarus 1.8.0 SVN revision number as well as fpc 3.0.4 svn revision number, please? I suspect there has been some changes between your release and mine that gives me troubles. Thank you. ---------------------------------------------------------------------- WooBean · 2018-04-23 14:13 Quote from: ertank on April 23, 2018, 03:30:26 pmHello WooBean, Would you advise if Lazarus 1.8.0 SVN revision number as well as fpc 3.0.4 svn revision number, please? I suspect there has been some changes between your release and mine that gives me troubles. Thank you. It will not help you, but anyway - for compiling I used officially distributed Laz. 1.8.0 SVN rev. 56594, FPC 3.0.4. - no SVN. This is from "About Lazarus" info. SVN numbering and presenting in IDE seems odd for me. The main difference from original code was changing a platform target, processor and widgetset. WooBean ---------------------------------------------------------------------- ertank · 2018-04-23 18:25 As it is indicated before. Problem is somewhere in LCL and on Lazarus side. I have downloaded setup and tested 1.8.2 and it failed. I have downloaded setup and tested 1.8.0 and it failed. Then I reverted back to my known to be working version and I confirm that I have no problem and everything works on lazarus/trunk svn 52504 (that is an old, version displayed as 1.7.0) So, there are some changes between svn 52504 and 56594 that breaks displaying forms (modal or normal) created at run-time. Once I have time, I will try to find exact modification and post in here. Just for the record. Problem cannot be observed on Win32 platform (aka regular windows) it does appear on handheld devices running WindowsCE OS. Thanks. ---------------------------------------------------------------------- jamie · 2018-04-24 00:43 Try createNew(Self) instead; Maybe the form is trying to access resources that do not exist ?