Results 1 to 5 of 5

Thread: Unset raster data pointer in QwtPlotSpectrogram without deleting it?

  1. #1
    Join Date
    Mar 2013
    Posts
    19
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Unset raster data pointer in QwtPlotSpectrogram without deleting it?

    Hi Uwe,
    I'm facing a small problem here related to my design.
    In my design, I have a QwtMatrixRasterData that is defined/declared in a class that handle IO and fill it with suited data. This class is also in charge of deleting this guy.
    But I realize that QwtPlotSpectrogram tries to delete also this raster data when the destructor is invoked. So I have a double free corruption happening. Is there a way to call a "unSetData()" method to remove the pointer stored in the QwtPlotSpectrogram then avoid to destroy it?
    Am I supposed to let QwtPlotSpectrogram destroy the QwtMatrixRasterData so that I have to change the way to address this data?

    I went down to the code and I saw that it is not implement the way I could have the raster data deleted outside. But probably their is a possibility?


    Thanks by advance.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Unset raster data pointer in QwtPlotSpectrogram without deleting it?

    QwtMatrixRasterData is a bridge between plot item and the real data, that is here stored as a QVector. What is the reason for keeping a copy such a bridge in your code ?

    Note that QVector is implicitly shared - like all Qt containers. So you can fill a QVector in your class and copy it then to the raster data object easily without any overhead.

    Uwe

  3. #3
    Join Date
    Mar 2013
    Posts
    19
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Unset raster data pointer in QwtPlotSpectrogram without deleting it?

    Thank Uwe,
    this is finally what I have done. I removed the QwtMatrixRasterData object from my IO class. I still have the QVector handled by this class.

    Since the QVector content can change (user move somewhere else to see another slice, for instance in depth) do I have to call following code each time QVector is updated?
    Qt Code:
    1. QwtMatrixRasterData* raster=dynamic_cast<QwtMatrixRasterData*>(spectro_seismic->data());
    2. raster->setValueMatrix(seismic->data(),seismic->nx());
    To copy to clipboard, switch view to plain text mode 

    I tried without but the updated content was not ploted.

    Thank again.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Unset raster data pointer in QwtPlotSpectrogram without deleting it?

    You are changing the data behind the back of the item - what means that its internal caches ( see QwtPlotRasterItem::invalidateCache() ) are not invalidated. Better create a new QwtMatrixRasterData object each time you are updating the value to avoid having to deal with them.

    Of course you also need to have a final replot to rebuild the plot.

    Uwe

  5. #5
    Join Date
    Mar 2013
    Posts
    19
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Unset raster data pointer in QwtPlotSpectrogram without deleting it?

    Ok,
    thanks for all.

Similar Threads

  1. Replies: 2
    Last Post: 29th July 2012, 19:09
  2. Replies: 2
    Last Post: 1st April 2012, 16:33
  3. Replies: 2
    Last Post: 16th October 2011, 23:25
  4. deleting invalid pointer
    By hollowhead in forum General Programming
    Replies: 11
    Last Post: 30th April 2010, 10:47
  5. deleting internal pointer in QModelIndex
    By rickbsgu in forum Qt Programming
    Replies: 18
    Last Post: 24th December 2008, 02:24

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.