[fixed] crash with chartEditor demo on double-clicking lazarus / 55-TAChart ---------------------------------------------------------------------- Muso · 2021-04-18 17:07 use the latest Laz 2.1 and the ChartEditor demo - set the Shift state of the click tools to "[ssLeft,ssDouble]" - run the program first (independent) result: 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 celegenddlg.pas(194,1) Warning: Function result variable does not seem to be initialized - double-click on the y-axis title - in the appearing dialog do nothing but press OK - again double-click on the y-axis title - again in the appearing dialog do nothing but press OK - now double-click on the legend - in the appearing dialog do nothing but press OK result: you get another dialog to change the grid of the x-axis - do nothing but click OK result: the program crashes (external sigsev) When run the program in debug mode, I get before the attached error: ---------------------------------------------------------------------- wp · 2021-04-18 17:33 I cannot reproduce this... Quote- in the appearing dialog do nothing but press OK result: you get another dialog to change the grid of the x-axis Does this mean that the x axis dialog appears after you close the legend dialog? How can this be? Your screenshots look as if you are on Win10. Which bitness is your Lazarus, 32bit or 64bit? What are your compiler settings? ---------------------------------------------------------------------- Muso · 2021-04-18 17:53 Quote from: wp on April 18, 2021, 07:33:55 pmDoes this mean that the x axis dialog appears after you close the legend dialog? Yes, it opens with the Grid tab opened, see attached. I see now that the crash is not reproducible in any case. To trigger the crash, repeat the sequence - y-axis double click, then OK - y-axis double click, then OK - legend double click, then OK up to 4 times. With this recipe I get the extra dialog and hence the crash every time. QuoteYour screenshots look as if you are on Win10. Which bitness is your Lazarus, 32bit or 64bit? What are your compiler settings? I have this: Lazarus 2.1.0 r65021 FPC 3.2.0 x86_64-win64-win32/win64 ---------------------------------------------------------------------- wp · 2021-04-18 18:32 No crash... ---------------------------------------------------------------------- Muso · 2021-04-18 21:47 Quote from: wp on April 18, 2021, 08:32:29 pmNo crash... For the demo he crash is gone with this commit: https://github.com/gra emeg/lazarus/commit/3177e3f2d5412c0097959ce4093860e891f5bd17 But for my project in which I use the code, it still crashes. I am a bit lost because when I debug, everything is fine on the first double- click. When I subsequently double-click on an axis, I get now at the beginning of TAxisEditor.Prepare(Axis: TChartAxis;  ACaptionMask: String) that FSavedAxis is not nil, but $f0f0.. see the attached image. It crashes then at this line: 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 FSavedAxis.Assign(FAxis); When I now comment out the if nil check, Assign() works, but it crashes  later on setting the caption. I can for example write Caption:= 'hello' and it crashes then at the first line of function TControl.GetText: TCaption; in control.inc. ---------------------------------------------------------------------- Muso · 2021-04-18 22:32 Attached is a test case. Run it and then - double-click on the left axis title - press OK in the dialog - again double-click on the left axis title - again press OK in the dialog result: the crash I described above. I use Lazarus 2.1.0 r65023 FPC 3.2.0 x86_64-win64-win32/win64 ---------------------------------------------------------------------- wp · 2021-04-19 08:04 I can confirm the issue now. Looking into it... P.S. Is there a special reason why the application is supposed to run at highest execution level? ---------------------------------------------------------------------- wp · 2021-04-19 09:45 You free the TAxisEditor at the end of the routine, but do not re- create it again. The reason that it is working at the first click is that you have the form in the list of auto-created forms. So, you either remove the call to AxisEditor.Free (as well as the enclosing try-finally which is not needed any more) or you use a local variable for TAxisEditor which you create and free in your routine: 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 var  lAxisEditor: TAxisEditor;begin  ...  lAxisEditor := TAxisEditor.Create(nil);  try    lAxisEditor.Prepare(AnAxis, 'Edit chart axis "%s"');    lAxisEditor.Page:= page;    lAxisEditor.ShowModal;   finally    lAxisEditor.Free;  end;end;  In the latter case, I would also recommend to remove the AxisEditor form from the list of auto-created forms (because you don't need the AxisEditor all the time). ---------------------------------------------------------------------- Muso · 2021-04-19 12:39 Quote from: wp on April 19, 2021, 10:04:49 amP.S. Is there a special reason why the application is supposed to run at highest execution level? I don't know. Where can I set this? Quote from: wp on April 19, 2021, 11:45:18 amSo, you either remove the call to AxisEditor.Free Many thanks. What a stupid mistake from me! ---------------------------------------------------------------------- wp · 2021-04-19 12:53 Quote from: Muso on April 19, 2021, 02:39:32 pmQuote from: wp on April 19, 2021, 10:04:49 amP.S. Is there a special reason why the application is supposed to run at highest execution level? I don't know. Where can I set this? First page of the project options. Below "Use manifest resource" there is a combobox "Execution level". Its default is "as invoker", and this is ok for most applications. But you had set it to "highest available". I noticed this because this setting made the debugger refuse to run the application. ---------------------------------------------------------------------- Muso · 2021-04-19 13:12 The crash is still in the demo and it seems to be a click handler issue because it is hard to reproduce. Here is my best recipe: - run the demo - use option for double-clicking - double-click on the y-axis title - do nothing but wait 2 s - now click OK - wait 2 s - double-click on the chart title - do nothing but wait 2 s - now click OK - in case you cannot trigger the issue, repeat the steps up to 10 times result: you get now an extra dialog about changing the axis grid. When you press there OK, it crashes. --------------- Quote from: wp on April 19, 2021, 02:53:03 pmFirst page of the project options. Below "Use manifest resource" there is a combobox "Execution level". Thanks. But strange because I never purposely changed this and also no other program of mine has this setting. ---------------------------------------------------------------------- wp · 2021-04-19 21:18 You mean the demo in TAChart, don't you? But again, I cannot reproduce the issue. But maybe the bug has disappeared now, because I refactored a lot of the demo today and fixed many more bugs. ---------------------------------------------------------------------- Muso · 2021-04-20 00:46 Quote from: wp on April 19, 2021, 11:18:09 pmYou mean the demo in TAChart, don't you? But again, I cannot reproduce the issue. But maybe the bug has disappeared now, because I refactored a lot of the demo today and fixed many more bugs. Yes, I mean the TAChart demo. I upgraded now and can no longer reproduce the crash. Many thanks. Only the minor UI issue remains, I reported here: https://forum.lazarus.freepascal.org/index.php/topic,54238.0.html