Results 1 to 3 of 3

Thread: crash after QGraphicsProxyWidget is removed from a scene

  1. #1
    Join Date
    May 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Question crash after QGraphicsProxyWidget is removed from a scene

    Hi

    I have a simple scene with a QGraphicsProxyWidget added to it ( and some widget set on it ). If I try removing it from the scene, like so:
    Qt Code:
    1. if ( widget )
    2. {
    3. parentScene->removeItem( m_widget ); // m_widget is a QGraphicsProxyWidget
    4. delete m_widget; // I also tried m_widget->deleteLater() here - same result
    5. m_widget = NULL;
    6. }
    To copy to clipboard, switch view to plain text mode 

    I get an instant crash - no descriptive callstack though that would tell me what's wrong ( some windows related calls in the callstack, and that's all ).

    I'm using version 5.1.1 of the Qt library, I've searched the manual and the net for an instruction how to actually remove such a widget, and it's not documented at all, so I'm not sure if I'm doing something wrong there, or is there a bug in the library.

    I'd appreciate any help.
    Cheers,
    Piotr

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: crash after QGraphicsProxyWidget is removed from a scene

    Maybe the widget get deleted, triggers a delete of the proxy and you delete is then a double delete.

    Have you tried just deleting the item, i.e. without removing it from the scene?

    Cheers,
    _

  3. #3
    Join Date
    May 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: crash after QGraphicsProxyWidget is removed from a scene

    It gets deleted, but as a result of the proxy being deleted, so that's not it


    Added after 4 minutes:


    There are 2 additional circumstances:

    - the crash doesn't occur until I make a scene query ( i.e. QGraphicsScene::items( QpointF() ... )
    - I'm calling hide/show on the embedded widget. If I stop doing that, the crashing stops.


    Added after 46 minutes:


    I found the problem - seemingly unrelated call to 'prepareGeometryChange' was to blame here.
    My widgets were changing size ( I didn't mention it, 'cause it seemed irrelevant at the time ). However I was calling the aforementioned method AFTER I made the change to the geometry, not before, as the manual instructs.

    Apparently that method is very important in order to keep the scene's internal data in order, and due to my calling it incorrectly, it was leaving some invalid references to the deleted items.
    Last edited by paksas; 9th February 2014 at 23:28.

Similar Threads

  1. QTableView: get the value of a removed column
    By trallallero in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2013, 16:05
  2. QtTelnet class removed
    By Helene Cormier in forum Qt Programming
    Replies: 4
    Last Post: 2nd June 2012, 08:28
  3. Replies: 4
    Last Post: 30th August 2010, 15:37
  4. Markers are not removed from QwtPlot
    By MuzZviman in forum Qwt
    Replies: 1
    Last Post: 3rd June 2010, 08:25
  5. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 18:51

Tags for this Thread

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.