Recent

Author Topic: [fixed] crash with chartEditor demo on double-clicking  (Read 3279 times)

Muso

  • Sr. Member
  • ****
  • Posts: 356
[fixed] crash with chartEditor demo on double-clicking
« on: April 18, 2021, 07:07:15 pm »
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][+][-]
  1. 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:
« Last Edit: April 20, 2021, 02:46:50 am by Muso »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: crash with chartEditor demo on double-clicking
« Reply #1 on: April 18, 2021, 07:33:55 pm »
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?
« Last Edit: April 18, 2021, 07:39:25 pm by wp »

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: crash with chartEditor demo on double-clicking
« Reply #2 on: April 18, 2021, 07:53:08 pm »
Does 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.

Quote
Your 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

  • Hero Member
  • *****
  • Posts: 11830
Re: crash with chartEditor demo on double-clicking
« Reply #3 on: April 18, 2021, 08:32:29 pm »
No crash...

Muso

  • Sr. Member
  • ****
  • Posts: 356
Re: crash with chartEditor demo on double-clicking
« Reply #4 on: April 18, 2021, 11:47:58 pm »
No crash...

For the demo he crash is gone with this commit: https://github.com/graemeg/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][+][-]
  1. 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

  • Sr. Member
  • ****
  • Posts: 356
Re: crash with chartEditor demo on double-clicking
« Reply #5 on: April 19, 2021, 12:32:21 am »
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

  • Hero Member
  • *****
  • Posts: 11830
Re: crash with chartEditor demo on double-clicking
« Reply #6 on: April 19, 2021, 10:04:49 am »
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

  • Hero Member
  • *****
  • Posts: 11830
Re: crash with chartEditor demo on double-clicking
« Reply #7 on: April 19, 2021, 11:45:18 am »
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][+][-]
  1. var
  2.   lAxisEditor: TAxisEditor;
  3. begin
  4.   ...
  5.   lAxisEditor := TAxisEditor.Create(nil);
  6.   try
  7.     lAxisEditor.Prepare(AnAxis, 'Edit chart axis "%s"');
  8.     lAxisEditor.Page:= page;
  9.     lAxisEditor.ShowModal;
  10.    finally
  11.     lAxisEditor.Free;
  12.   end;
  13. 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

  • Sr. Member
  • ****
  • Posts: 356
Re: crash with chartEditor demo on double-clicking
« Reply #8 on: April 19, 2021, 02:39:32 pm »
P.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?

So, you either remove the call to AxisEditor.Free

Many thanks. What a stupid mistake from me!

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: crash with chartEditor demo on double-clicking
« Reply #9 on: April 19, 2021, 02:53:03 pm »
P.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

  • Sr. Member
  • ****
  • Posts: 356
Re: [still there] crash with chartEditor demo on double-clicking
« Reply #10 on: April 19, 2021, 03:12:51 pm »
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.

---------------

First 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

  • Hero Member
  • *****
  • Posts: 11830
Re: [still there] crash with chartEditor demo on double-clicking
« Reply #11 on: April 19, 2021, 11:18:09 pm »
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

  • Sr. Member
  • ****
  • Posts: 356
Re: [still there] crash with chartEditor demo on double-clicking
« Reply #12 on: April 20, 2021, 02:46:37 am »
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.

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

 

TinyPortal © 2005-2018