Results 1 to 2 of 2

Thread: same QwtColorMap object in plot and color-bar causes crash

  1. #1
    Join Date
    Feb 2008
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question same QwtColorMap object in plot and color-bar causes crash

    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
    Qt Code:
    1. d_spectrogram->setColorMap( new ColorMap());
    2. 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
    Qt Code:
    1. ColorMap * map = new ColorMap();
    2. d_spectrogram->setColorMap( map );
    3. 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

  2. The following user says thank you to rainman110 for this useful post:

    alketi (13th February 2019)

  3. #2
    Join Date
    Dec 2011
    Posts
    60
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: same QwtColorMap object in plot and color-bar causes crash

    Well, almost 8 years later and I just ran into this same issue. My spectrogram app crashing on exit. Ouch. I've spent more time searching and looking through valgrind outputs to find the cause than I'll admit.

    In case anyone else finds this, you have to create separate ColorMap instances and feed them separately into the Spectrogram and Axis objects. You cannot reuse a single object as you would do elsewhere in Qt, or your Qwt app will crash on exit with a double-delete.

    Uwe, if you're still supporting the project, it would be really nice if Qwt used QPointers (or similar) internally to prevent this issue, or at least, documented it in the QwtSpectrogram class. Great library otherwise. Cheers.

Similar Threads

  1. Crash on deletion of QScriptEngine object
    By rajeshclt3 in forum Qt Programming
    Replies: 4
    Last Post: 11th August 2011, 08:48
  2. Crash on deletion of QScriptEngine object
    By The_Fallen in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2010, 10:27
  3. Replies: 1
    Last Post: 1st February 2010, 16:13
  4. Replies: 2
    Last Post: 12th October 2009, 22:17
  5. Replies: 0
    Last Post: 27th May 2008, 02:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.