Results 1 to 4 of 4

Thread: QPainter crash when generating icon after drag-drop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Location
    Beijing, China
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPainter crash when generating icon after drag-drop

    That does indeed prevent a crash. I thought I had solved it by moving the update() call that was coming from a successful drop on the target side to just after [QDrag]->exec() on the source side (using the drop target from QDrag info).

    Now you've made me think about what's happening here more carefully. Does that mean that the QIcon keeps hold of the QPixmap? If I do create it on the heap, who's reponsible for deleting it? Apologies if this seems like a daft question...

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QPainter crash when generating icon after drag-drop

    Does that mean that the QIcon keeps hold of the QPixmap?
    No, it means exactly the opposite.
    If the QIcon had its own deep copy, it wouldn't need the external pixmap object to stay alive.

    If I do create it on the heap, who's reponsible for deleting it? Apologies if this seems like a daft question...
    Not darf at all, would be better if more people would think that far to ask it.
    The answer depends on how you allocate your pixmap.
    If you give it a QObject parent, you don't have to worry about destruction, the parent will.
    If its parent-less, you will have to take care of deleting it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 2
    Last Post: 13th October 2010, 21:51
  2. QListWidgetItem subclass - Crash program in drag/drop
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2009, 09:24
  3. Replies: 20
    Last Post: 15th August 2008, 23:19
  4. Icon Change in Drag & Drop
    By joseph in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2006, 12:03
  5. Replies: 5
    Last Post: 23rd May 2006, 11:40

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
  •  
Qt is a trademark of The Qt Company.