PDA

View Full Version : QwtPlotMarker segfault



viridis
28th August 2008, 12:16
Hi,

I am trying to use a QwtPlotMarker to show "the current step" in my graph with a vertical line.

I have created my marker, attached it to my graph, changed lineStyle, linePen... just like in the "bode" example.

When I run the application, it crash.. but it is quite strange.
When I create my marker, I call setValue and everything goes fine (except that the marker is not shown in the plot).
Then, I call setValue again each time my "current step" change and this is where the segfault appens.

The crash occurs just after the "itemChanged()" call in QwtPlotMarker::setValue(double, double).

To be noted that it crash only when I change the xBottomScale with setAxisScale and setAxisTitle.

Any idea ?

jacek
28th August 2008, 21:21
To be noted that it crash only when I change the xBottomScale with setAxisScale and setAxisTitle.
What arguments do you pass to these methods?

viridis
29th August 2008, 08:12
setAxisScale(QwtPlot::xBottom, fromValue, toValue);
setAxisTitle(QwtPlot::xBottom, "my axis title");

fromValue and toValue represent the min and max of my xScale (in x values, not pixels).
Indeed, I manipulate the x and y scales myself to be able to draw multiple curves which have different scales. Next, I can change the axis scale (only the Y one as all my curve have the same time base) according to the selected curve.

viridis
16th September 2008, 15:23
After digging a little, it appears that in QwtPlotMarker constructor, the line "d_data = new PrivateData" allocates a private data object which is fine (allocation works as espected).

Then I add curves, I change my scales...
And then, when I do my "setValue" call on the marker, the "d_data" member points to a invalid location (0xfdfdfd) which was not the case before.

viridis
17th September 2008, 13:22
Ok, well, I found the bug which was, of course, in my code.
I thought QwtPlot::clear() will remove only curves, but markers are too...