Error while execution - Can someone help me with the debugger information lazarus / 12-Debugger ---------------------------------------------------------------------- teochris · 2016-02-05 19:01 My project has a main form and some other popup forms that interact with the main form through button clicks When the user clicks a button in the main form then a popup form comes to front and after user does someselections then the popup form send to the main form commands like the following one 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 TzokerApp.NumbButton01Click(Self) and then the popup form closes and everything until now is ok BUT if the user clicks again the button to reopen the popup form I get the following crash message Project tzoker raised exception class ' External: SIGSEGV' in file ... at line ... That line in my program says     PopUpRandom.Showmodal;  and it is in the button onclick event procedure. If in the popup window I remove the code that sends to main form the self onclick events then everything works properly. Can someone please read and help me understand what is the problem from the debugger info (I will add it in my next posts) Here you can download a copy of the unfinished app and see the crash yourself ---------------------------------------------------------------------- teochris · 2016-02-05 19:05 This is the code the debugger creates after the crash occurs 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 *stopped,reason="signal-received",signal-name="SIGSEGV",signal- meaning="Segmentation fault",frame={addr="0x0042934d",func="TTZOKERAPP __TYXAIESEPILOGESCLICK",args=[{name="SENDER",value="0x6d25f68"},{name= "this",value="0x242aa28"}],file="tzoker_main_greek.pas",fullname="C:\\ Users\\afroditi\\Desktop\\\310\357\344\376\361\347\362\\Diafora progra mmatismou\\Tzoker_projects\\0021\\tzoker_main_greek.pas",line="1919"}, thread-id="1",stopped-threads="all"(gdb) &"info program\n"~"\tUsing the running image of child Thread 32.0x1b8c.\n"~"Program stopped at 0x42934d.\n"~"It stopped with signal SIGSEGV, Segmentation fault.\n"^done(gdb) <-thread- info>^done,threads=[{id="8",target-id="Thread 32.0xa1c",frame={level=" 0",addr="0x775c70ac",func="ntdll!ZwWaitForMultipleObjects",args=[],fro m="C:\\WINDOWS\\SYSTEM32\\ntdll.dll"},state="stopped"},{id="7",target- id="Thread 32.0xf60",frame={level="0",addr="0x775c70ac",func="ntdll!Zw WaitForMultipleObjects",args=[],from="C:\\WINDOWS\\SYSTEM32\\ntdll.dll "},state="stopped"},{id="6",target-id="Thread 32.0x2364",frame={level= "0",addr="0x775c868c",func="ntdll!ZwWaitForWorkViaWorkerFactory",args= [],from="C:\\WINDOWS\\SYSTEM32\\ntdll.dll"},state="stopped"},{id="5",t arget-id="Thread 32.0x1c74",frame={level="0",addr="0x775c868c",func="n tdll!ZwWaitForWorkViaWorkerFactory",args=[],from="C:\\WINDOWS\\SYSTEM3 2\\ntdll.dll"},state="stopped"},{id="4",target-id="Thread 32.0x174",fr ame={level="0",addr="0x775c868c",func="ntdll!ZwWaitForWorkViaWorkerFac tory",args=[],from="C:\\WINDOWS\\SYSTEM32\\ntdll.dll"},state="stopped" },{id="3",target-id="Thread 32.0x2398",frame={level="0",addr="0x775c86 8c",func="ntdll!ZwWaitForWorkViaWorkerFactory",args=[],from="C:\\WINDO WS\\SYSTEM32\\ntdll.dll"},state="stopped"},{id="2",target-id="Thread 3 2.0x184c",frame={level="0",addr="0x775c868c",func="ntdll!ZwWaitForWork ViaWorkerFactory",args=[],from="C:\\WINDOWS\\SYSTEM32\\ntdll.dll"},sta te="stopped"},{id="1",target-id="Thread 32.0x1b8c",frame={level="0",ad dr="0x0042934d",func="TTZOKERAPP__TYXAIESEPILOGESCLICK",args=[{name="S ENDER",value="0x6d25f68"},{name="this",value="0x242aa28"}],file="tzoke r_main_greek.pas",fullname="C:\\Users\\afroditi\\Desktop\\\310\357\344 \376\361\347\362\\Diafora programmatismou\\Tzoker_projects\\0021\\tzok er_main_greek.pas",line="1919"},state="stopped"}],current-thread- id="1"(gdb) <-stack-info-depth 11>^done,depth="11"(gdb) <-stack-list- arguments 1 0 4>^done,stack-args=[frame={level="0",args=[{name="SENDER ",value="0x6d25f68"},{name="this",value=""}]},frame={level="1",args=[{name="this",value=""}]},frame={level="2",args=[{name="this",value=""}]},frame={level="3",args=[{name="this",value=""}]},frame={level="4",args=[{name="MESSAGE",value="{MSG = 66567, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, WPARAMFILLER = {}, LPARAMLO = 0, LPARAMHI = 0, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}"},{name="this",value=""}]}](gdb) <-stack- list-frames 0 4>^done,stack=[frame={level="0",addr="0x0042934d",func=" TTZOKERAPP__TYXAIESEPILOGESCLICK",file="tzoker_main_greek.pas",fullnam e="C:\\Users\\afroditi\\Desktop\\\310\357\344\376\361\347\362\\Diafora programmatismou\\Tzoker_projects\\0021\\tzoker_main_greek.pas",line="1 919"},frame={level="1",addr="0x0050a335",func="TCONTROL__CLICK",file=" ./include/control.inc",fullname="c:/temp/lazbuild/lcl//./include/contr ol.inc",line="2736"},frame={level="2",addr="0x00520240",func="TBUTTONC ONTROL__CLICK",file="./include/buttoncontrol.inc",fullname="c:/temp/la zbuild/lcl//./include/buttoncontrol.inc",line="54"},frame={level="3",a ddr="0x00520916",func="TCUSTOMBUTTON__CLICK",file="./include/buttons.i nc",fullname="c:/temp/lazbuild/lcl//./include/buttons.inc",line="169"} ,frame={level="4",addr="0x0052014b",func="TBUTTONCONTROL__WMDEFAULTCLI CKED",file="./include/buttoncontrol.inc",fullname="c:/temp/lazbuild/lc l//./include/buttoncontrol.inc",line="20"}](gdb) <-stack-list- arguments 1 0 0>^done,stack-args=[frame={level="0",args=[{name="SENDER ",value="0x6d25f68"},{name="this",value=""}]}](gdb) <-stack-list-locals 1>^done,locals=[{name="SENDER",value="0x6d25f68"}](gdb) ---------------------------------------------------------------------- teochris · 2016-02-05 19:07 And this is the code the debugger creates after the app crashes and I click the ok button 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 &"kill\n"=thread-exited,id="8",group-id="i1"=thread- exited,id="7",group-id="i1"=thread-exited,id="6",group-id="i1"=thread- exited,id="5",group-id="i1"=thread-exited,id="4",group-id="i1"=thread- exited,id="3",group-id="i1"=thread-exited,id="2",group-id="i1"=thread- exited,id="1",group-id="i1"=thread-group-exited,id="i1"^done(gdb) &"info program\n"~"The program being debugged is not being run.\n"^done(gdb) <-break-delete 17>^done(gdb) <-break-delete 18>^done(gdb) <-break-delete 19>^done(gdb) <-file-exec-and-symbols >=library-unloaded,id="C:\\WINDOWS\\SysWOW64\\kernel32.dll",target- name="C:\\WINDOWS\\SysWOW64\\kernel32.dll",host- name="C:\\WINDOWS\\SysWOW64\\kernel32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\KernelBase.dll",target- name="C:\\WINDOWS\\SysWOW64\\KernelBase.dll",host- name="C:\\WINDOWS\\SysWOW64\\KernelBase.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\oleaut32.dll",target- name="C:\\WINDOWS\\SysWOW64\\oleaut32.dll",host- name="C:\\WINDOWS\\SysWOW64\\oleaut32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\msvcrt.dll",target- name="C:\\WINDOWS\\SysWOW64\\msvcrt.dll",host- name="C:\\WINDOWS\\SysWOW64\\msvcrt.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\combase.dll",target- name="C:\\WINDOWS\\SysWOW64\\combase.dll",host- name="C:\\WINDOWS\\SysWOW64\\combase.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\rpcrt4.dll",target- name="C:\\WINDOWS\\SysWOW64\\rpcrt4.dll",host- name="C:\\WINDOWS\\SysWOW64\\rpcrt4.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\sspicli.dll",target- name="C:\\WINDOWS\\SysWOW64\\sspicli.dll",host- name="C:\\WINDOWS\\SysWOW64\\sspicli.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\cryptbase.dll",target- name="C:\\WINDOWS\\SysWOW64\\cryptbase.dll",host- name="C:\\WINDOWS\\SysWOW64\\cryptbase.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\bcryptprimitives.dll",target- name="C:\\WINDOWS\\SysWOW64\\bcryptprimitives.dll",host- name="C:\\WINDOWS\\SysWOW64\\bcryptprimitives.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\sechost.dll",target- name="C:\\WINDOWS\\SysWOW64\\sechost.dll",host- name="C:\\WINDOWS\\SysWOW64\\sechost.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\user32.dll",target- name="C:\\WINDOWS\\SysWOW64\\user32.dll",host- name="C:\\WINDOWS\\SysWOW64\\user32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\gdi32.dll",target- name="C:\\WINDOWS\\SysWOW64\\gdi32.dll",host- name="C:\\WINDOWS\\SysWOW64\\gdi32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\shell32.dll",target- name="C:\\WINDOWS\\SysWOW64\\shell32.dll",host- name="C:\\WINDOWS\\SysWOW64\\shell32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\cfgmgr32.dll",target- name="C:\\WINDOWS\\SysWOW64\\cfgmgr32.dll",host- name="C:\\WINDOWS\\SysWOW64\\cfgmgr32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\version.dll",target- name="C:\\WINDOWS\\SysWOW64\\version.dll",host- name="C:\\WINDOWS\\SysWOW64\\version.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\windows.storage.dll",target- name="C:\\WINDOWS\\SysWOW64\\windows.storage.dll",host- name="C:\\WINDOWS\\SysWOW64\\windows.storage.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\advapi32.dll",target- name="C:\\WINDOWS\\SysWOW64\\advapi32.dll",host- name="C:\\WINDOWS\\SysWOW64\\advapi32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\shlwapi.dll",target- name="C:\\WINDOWS\\SysWOW64\\shlwapi.dll",host- name="C:\\WINDOWS\\SysWOW64\\shlwapi.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\kernel.appcore.dll",target- name="C:\\WINDOWS\\SysWOW64\\kernel.appcore.dll",host- name="C:\\WINDOWS\\SysWOW64\\kernel.appcore.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\SHCore.dll",target- name="C:\\WINDOWS\\SysWOW64\\SHCore.dll",host- name="C:\\WINDOWS\\SysWOW64\\SHCore.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\powrprof.dll",target- name="C:\\WINDOWS\\SysWOW64\\powrprof.dll",host- name="C:\\WINDOWS\\SysWOW64\\powrprof.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\profapi.dll",target- name="C:\\WINDOWS\\SysWOW64\\profapi.dll",host- name="C:\\WINDOWS\\SysWOW64\\profapi.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\ole32.dll",target- name="C:\\WINDOWS\\SysWOW64\\ole32.dll",host- name="C:\\WINDOWS\\SysWOW64\\ole32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\WinSxS\\x86_microsoft.windows.common-control s_6595b64144ccf1df_6.0.10586.0_none_d3c2e4e965da4528\\comctl32.dll",ta rget-name="C:\\WINDOWS\\WinSxS\\x86_microsoft.windows.common-controls_ 6595b64144ccf1df_6.0.10586.0_none_d3c2e4e965da4528\\comctl32.dll",host -name="C:\\WINDOWS\\WinSxS\\x86_microsoft.windows.common-controls_6595 b64144ccf1df_6.0.10586.0_none_d3c2e4e965da4528\\comctl32.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SYSTEM32\\ntdll.dll",target- name="C:\\WINDOWS\\SYSTEM32\\ntdll.dll",host- name="C:\\WINDOWS\\SYSTEM32\\ntdll.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\imm32.dll",target- name="C:\\WINDOWS\\SysWOW64\\imm32.dll",host- name="C:\\WINDOWS\\SysWOW64\\imm32.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\uxtheme.dll",target- name="C:\\WINDOWS\\SysWOW64\\uxtheme.dll",host- name="C:\\WINDOWS\\SysWOW64\\uxtheme.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\msimg32.dll",target- name="C:\\WINDOWS\\SysWOW64\\msimg32.dll",host- name="C:\\WINDOWS\\SysWOW64\\msimg32.dll",thread-group="i1"=library- unloaded,id="C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\Ink\\tiptsf.dll",target-name="C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\Ink\\tiptsf.dll",host-name="C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\Ink\\tiptsf.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\msctf.dll",target- name="C:\\WINDOWS\\SysWOW64\\msctf.dll",host- name="C:\\WINDOWS\\SysWOW64\\msctf.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\dwmapi.dll",target- name="C:\\WINDOWS\\SysWOW64\\dwmapi.dll",host- name="C:\\WINDOWS\\SysWOW64\\dwmapi.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\clbcatq.dll",target- name="C:\\WINDOWS\\SysWOW64\\clbcatq.dll",host- name="C:\\WINDOWS\\SysWOW64\\clbcatq.dll",thread-group="i1"=library- unloaded,id="C:\\Windows\\SysWOW64\\UIAutomationCore.dll",target- name="C:\\Windows\\SysWOW64\\UIAutomationCore.dll",host- name="C:\\Windows\\SysWOW64\\UIAutomationCore.dll",thread- group="i1"=library- unloaded,id="C:\\Windows\\SysWOW64\\userenv.dll",target- name="C:\\Windows\\SysWOW64\\userenv.dll",host- name="C:\\Windows\\SysWOW64\\userenv.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\sxs.dll",target- name="C:\\WINDOWS\\SysWOW64\\sxs.dll",host- name="C:\\WINDOWS\\SysWOW64\\sxs.dll",thread-group="i1"=library- unloaded,id="C:\\Windows\\SysWOW64\\oleacc.dll",target- name="C:\\Windows\\SysWOW64\\oleacc.dll",host- name="C:\\Windows\\SysWOW64\\oleacc.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\twinapi.dll",target- name="C:\\WINDOWS\\SysWOW64\\twinapi.dll",host- name="C:\\WINDOWS\\SysWOW64\\twinapi.dll",thread-group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\twinapi.appcore.dll",target- name="C:\\WINDOWS\\SysWOW64\\twinapi.appcore.dll",host- name="C:\\WINDOWS\\SysWOW64\\twinapi.appcore.dll",thread- group="i1"=library- unloaded,id="C:\\WINDOWS\\SysWOW64\\bcrypt.dll",target- name="C:\\WINDOWS\\SysWOW64\\bcrypt.dll",host- name="C:\\WINDOWS\\SysWOW64\\bcrypt.dll",thread-group="i1"^done(gdb) ---------------------------------------------------------------------- FTurtle · 2016-02-05 19:49 If you want to get help, better post here the code snippets of two forms which related with the problem. In particular: 1. How the second form created. 2. How do you show it. 3. What it does. 4. How it closes. 5. How it destroyed. ---------------------------------------------------------------------- teochris · 2016-02-05 19:55 Quote from: FTurtle on February 05, 2016, 08:49:54 pmIf you want to get help, better post here the code snippets of two forms which related with the problem. In particular: 1. How the second form created. 2. How do you show it. 3. What it does. 4. How it closes. 5. How it destroyed. Hmmm you already gave me a clue! 5. How it destroyed I do not destroy it I just close it and then i reopen it Do I have to destroy it after close? How do i do so? ---------------------------------------------------------------------- FTurtle · 2016-02-05 20:11 Quote from: teochris on February 05, 2016, 08:55:40 pmI do not destroy it I just close it and then i reopen it Do I have to destroy it after close? It depends on your goals. Often modal forms are created before showing and destroyed  immediately after closing. For example: 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);begin  with TForm2.Create(nil) do  try    ShowModal;  finally    Free;  end;end; However, this is not always the case. Form can be shown few times without destroying. ---------------------------------------------------------------------- FTurtle · 2016-02-05 20:34 It seems to me your problem is related with the way of closing the form. But without code nothing to say about this. ---------------------------------------------------------------------- teochris · 2016-02-05 21:22 Quote from: FTurtle on February 05, 2016, 09:34:11 pmIt seems to me your problem is related with the way of closing the form. But without code nothing to say about this. I have 2 buttons to close the form and i have tried all available combinations. The second button does not call onclick procedures from the first form and when ever i close the popup form with it then no problem occurs at all The first button that does call onclick procedures from the first form after i close the popup form with this button then the problem appears! Both buttons close the popup form the same way! ---------------------------------------------------------------------- FTurtle · 2016-02-05 22:23 My answer without code: "you do something wrong". See here and do the same way: http://forum.lazarus.freepascal.org/index.php/topic,31410.0.html P.S. Nobody will run executable file from unknown source. ---------------------------------------------------------------------- Windsurfer · 2016-02-05 23:32 I use the following code for a pop-up form that I need to have active at the same time as the main form. 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 TfrmMainScreen.SpdBtnPopupClick(Sender: TObject);begin  if frmPopup <> nil then    frmPopup.Show  else  begin    frmPopup := TfrmPopup.Create(Application);    frmPopup.Show;  end;end; Then in a Close bitbutton on the pop-up form I set kind to bkClose and ModalResult to mrClose; This allows me to open as many forms at a time as I like. ---------------------------------------------------------------------- taazz · 2016-02-06 06:53 Quote from: Windsurfer on February 06, 2016, 12:32:08 amI use the following code for a pop-up form that I need to have active at the same time as the main form. 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 TfrmMainScreen.SpdBtnPopupClick(Sender: TObject);begin  if frmPopup <> nil then    frmPopup.Show  else  begin    frmPopup := TfrmPopup.Create(Application);    frmPopup.Show;  end;end; Then in a Close bitbutton on the pop-up form I set kind to bkClose and ModalResult to mrClose; This allows me to open as many forms at a time as I like. that is half the solution. The other half is to set the frmPopup to nil when the form is destroyed. ---------------------------------------------------------------------- Thaddy · 2016-02-06 07:00 Quote from: taazz on February 06, 2016, 07:53:09 amthat is half the solution. The other half is to set the frmPopup to nil when the form is destroyed. Actually, it is just one third of the solution. As-is this code runs a high risk in running into a popup-behind scenario. Especially when the message bus is not completely empty yet. What you really also need to do is bring it to front as well. 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 frmPopup.Show;frmPopup.BringToFront;  That prevents a well known scenario that is even present in the Lazarus IDE and manifests itself always at the wrong time ---------------------------------------------------------------------- teochris · 2016-02-06 09:05 Quote from: Windsurfer on February 06, 2016, 12:32:08 am Then in a Close bitbutton on the pop-up form I set kind to bkClose and ModalResult to mrClose; I believe that you are giving me a very nice solution. Can you please also write for me the code that you use, for the close bitbutton so you can "set kind to bkClose and ModalResult to mrClose" window? Regards ---------------------------------------------------------------------- teochris · 2016-02-06 09:09 Quote from: taazz on February 06, 2016, 07:53:09 amthat is half the solution. The other half is to set the frmPopup to nil when the form is destroyed. How can i set frmPopup to nil when the form is destroyed? ---------------------------------------------------------------------- teochris · 2016-02-06 09:21 This seems to do the job just fine for me -  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     if PopUpRandom <> nil then      PopUpRandom.Show    else    begin      PopUpRandom := TPopUpRandom.Create(Application);      PopUpRandom.ShowModal;    end; When I get more information about how can I close properly the popup form and set it to nil then I will post the complete solution here! ---------------------------------------------------------------------- Windsurfer · 2016-02-06 10:07 Thaddy is right about 'BringToFront', although I have not had problems with it. I set the conditions in the Object Inspector. I always believed that closing a form like this destroyed it. The attachment shows the OI settings for the button. The form is just a normal form in my case so that several forms are active at the same time. ---------------------------------------------------------------------- taazz · 2016-02-06 10:10 Quote from: teochris on February 06, 2016, 10:09:30 amQuote from: taazz on February 06, 2016, 07:53:09 amthat is half the solution. The other half is to set the frmPopup to nil when the form is destroyed. How can i set frmPopup to nil when the form is destroyed? select the mainform that calls the frmpopup, go to the object inspector change to the events tab and locate the ondestroy event. Double click it to create the event and in there write something along the lines of Code: Delphi  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if Sender = frmPopup then frmPopup := nil; Now go to the object inspector and make sure that the ondestroy event is empty (you do not need it on the main form) then change your code to Code: Delphi  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if PopUpRandom <> nil then    frmPopup.Show  else begin    frmPopup := TPopUpRandom.Create(Application);    frmPopup.OnDestroy := @FormDestroy;    frmPopup.ShowModal;  end; and you are ready. Keep in mind that the event will only be available from the main form if the frmPopup is used from other forms the above procedure has to be written for those forms too. Do not be smart about this and merge it inside the frmPopup that will constrain you in to a single variable and that might interfere with forms other than the intended one, then again it might save you a lot of typing if this form has a singleton logic. ---------------------------------------------------------------------- taazz · 2016-02-06 10:22 Quote from: Windsurfer on February 06, 2016, 11:07:27 amThaddy is right about 'BringToFront', although I have not had problems with it. I set the conditions in the Object Inspector. I always believed that closing a form like this destroyed it. No the default behavior is determined from the type of form. If my memory serves me right all mdi child forms have a default behavior caMinimize not caFree and as always an onclose event can change that behavior to what ever the programmer needs it to be. ---------------------------------------------------------------------- Windsurfer · 2016-02-06 10:46 I just remembered making a wiki entry a while ago. see http://wiki.lazarus.freepascal.org/Testing,_if_form_exists The missing part is: 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 TMyForm.Formclose(Sender: Tobject; var Closeaction: Tcloseaction);begin  CloseAction := caFree;  MyForm := nil;End; However, I do not have this in my code, and I do not get memory leaks. ---------------------------------------------------------------------- taazz · 2016-02-06 11:05 Quote from: Windsurfer on February 06, 2016, 11:46:20 amI just remembered making a wiki entry a while ago. see http://wiki.lazarus.freepascal.org/Testing,_if_form_exists The missing part is: 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 TMyForm.Formclose(Sender: Tobject; var Closeaction: Tcloseaction);begin  CloseAction := caFree;  MyForm := nil;End; However, I do not have this in my code, and I do not get memory leaks. All autocreated forms are created with the Application as owner. That means that when application is destroyed it auto destroys all owned forms as well. As a consequence the trace unit will never show a memory leak. Your code shows that you also create the popup form with the application as the owner. Just to make things a bit clear when I said "do not be smart about it" on my last message that is the kind of code I mend. Personally I do not use the global variables at all and in the finished product they are all deleted before delivery to the client to avoid that kind of situations. ---------------------------------------------------------------------- Thaddy · 2016-02-06 15:23 Quote from: taazz on February 06, 2016, 11:22:52 amNo the default behavior is determined from the type of form. If my memory serves me right all mdi child forms have a default behavior caMinimize not caFree and as always an onclose event can change that behavior to what ever the programmer needs it to be. Huhmmmm... TS wanted behavior similar to a modal form, but with behavior like a normal form. In that case, bring to front. It is not ideal, but at least the form shows and stays there for a little So if you can't live with a modal  form (which is still not properly fixed for all platforms in Lazarus! and I am not going to fix basics) use BringToFront. ---------------------------------------------------------------------- taazz · 2016-02-06 15:50 Quote from: Thaddy on February 06, 2016, 04:23:36 pmQuote from: taazz on February 06, 2016, 11:22:52 amNo the default behavior is determined from the type of form. If my memory serves me right all mdi child forms have a default behavior caMinimize not caFree and as always an onclose event can change that behavior to what ever the programmer needs it to be. Huhmmmm... TS wanted behavior similar to a modal form, but with behavior like a normal form. That is not what he asked for though. He asked why although in surface he took all the measures to avoid SIGSEGV errors he still managed to get one. At least this is the one I answered. Quote from: Thaddy on February 06, 2016, 04:23:36 pmIn that case, bring to front. It is not ideal, but at least the form shows and stays there for a little So if you can't live with a modal  form (which is still not properly fixed for all platforms in Lazarus! and I am not going to fix basics) use BringToFront. Well there are different solutions to this problem if this is the problem he is facing. You can set the form to fsStayontop you can call bringtofront and because it might not work the first time around sendtoback and brigntofront again or you can use the popupParent to make sure that it will always stay on top of the calling form. If he has that problem. In any case since he did not post any problems I'm guessing we were successful pin pointing the problem he had and probably some he will get. ---------------------------------------------------------------------- Thaddy · 2016-02-06 17:00 @Taazz For know I consider fsStayontop as "wherever I decide I want you to stay.." op.cit Platform you choose, NOT you, but the platform. That's why I still am not fully comfortable with Lazarus, although I try to be (even polte, sometimes .... [edit] Just checked some code in the lcl. Scared the shit out of me...  and uhmmm, what does stay on top do: major sins all over the place. That's not proper in any case. ---------------------------------------------------------------------- taazz · 2016-02-06 20:56 Quote from: Thaddy on February 06, 2016, 06:00:11 pm@Taazz For know I consider fsStayontop as "wherever I decide I want you to stay.." op.cit Platform you choose, NOT you, but the platform. That's why I still am not fully comfortable with Lazarus, although I try to be (even polte, sometimes .... [edit] Just checked some code in the lcl. Scared the shit out of me...  and uhmmm, what does stay on top do: major sins all over the place. That's not proper in any case. I aggree. I tried long and hard to find a legitimate use of fsStayontop for an every day application and the only thing I come up with was on eye droper tool that selects a color from your desktop you create a fsStayontop form to show a dummy image of the desktop to let the user select a color after all those years of programming I come up with one legitimate use for it. Even the popupMode/PopupParent I only use under 2 or 3 conditions which they are less aggressive than the fsstayontop. Keep in mind that fsStayontop on lazarus does not have the same usage as the one in delphi. It supposed to stay on top of all the forms of your application only and fsSystemStayontop is suppose to stay on top of everything.