Hi,
the spectrogram example uses two separate color map objects to display the color-bar and the plot itself. In the code this is done by the lines
d_spectrogram->setColorMap( new ColorMap());
rightAxis->setColorMap( zInterval, new ColorMap());
d_spectrogram->setColorMap( new ColorMap());
rightAxis->setColorMap( zInterval, new ColorMap());
To copy to clipboard, switch view to plain text mode
Now in my real project (which is inspired by this example) I would like to maintain only one single colormap object, because it should be modified by the gui. However, if the same colormap object is given to the plot and the color-bar according to
ColorMap * map = new ColorMap();
d_spectrogram->setColorMap( map );
rightAxis->setColorMap( zInterval, map);
ColorMap * map = new ColorMap();
d_spectrogram->setColorMap( map );
rightAxis->setColorMap( zInterval, map);
To copy to clipboard, switch view to plain text mode
the application crashes during in the destructor because both the colorbar (QwtScaleWidget) and the plot try to delete the same object which results in a double delete. How can I avoid this behaviour? I think QWT needs smart pointers as QT does to avoid such problems. Are there any workarounds or should I keep 2 objects and keep them in sync?
Thanks, Martin
Bookmarks