Results 1 to 5 of 5

Thread: QProcess crashes when deleting it in the finished-handler

  1. #1
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QProcess crashes when deleting it in the finished-handler

    Hello,

    I'm trying to delete a QProcess in a method connected to the finished() signal, but this crashes with the following backtrace:
    Qt Code:
    1. #0 0xb748809d in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
    2. #1 0xb7488a2c in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
    3. #2 0xb74341ea in QProcess::finished () from /usr/lib/libQtCore_debug.so.4
    4. #3 0xb743559f in QProcessPrivate::processDied () from /usr/lib/libQtCore_debug.so.4
    5. #4 0xb7435686 in QProcess::qt_metacall () from /usr/lib/libQtCore_debug.so.4
    6. #5 0xb74885b1 in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
    7. #6 0xb7488a2c in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
    8. #7 0xb74a6241 in QSocketNotifier::activated () from /usr/lib/libQtCore_debug.so.4
    9. #8 0xb7490e22 in QSocketNotifier::event () from /usr/lib/libQtCore_debug.so.4
    10. #9 0xb75cc8b4 in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui_debug.so.4
    11. #10 0xb75cd8c9 in QApplication::notify () from /usr/lib/libQtGui_debug.so.4
    12. #11 0xb749b899 in QEventDispatcherUNIX::activateSocketNotifiers () from /usr/lib/libQtCore_debug.so.4
    13. #12 0xb749c506 in QEventDispatcherUNIXPrivate::doSelect () from /usr/lib/libQtCore_debug.so.4
    14. #13 0xb749d06b in QEventDispatcherUNIX::processEvents () from /usr/lib/libQtCore_debug.so.4
    15. #14 0xb76348e7 in QEventDispatcherX11::processEvents () from /usr/lib/libQtGui_debug.so.4
    16. #15 0xb7479a24 in QEventLoop::processEvents () from /usr/lib/libQtCore_debug.so.4
    17. #16 0xb7479c76 in QEventLoop::exec () from /usr/lib/libQtCore_debug.so.4
    18. #17 0xb747c611 in QCoreApplication::exec () from /usr/lib/libQtCore_debug.so.4
    19. #18 0xb75cc5d7 in QApplication::exec () from /usr/lib/libQtGui_debug.so.4
    20. #19 0x0808c857 in main (argc=1, argv=0xbfb40004) at main.cpp:79
    To copy to clipboard, switch view to plain text mode 

    When I comment out the deleting of the QProcess everything works fine (though I have a memory leak..).
    Has anyone encountered this problem? Is a bug report due, or is it a feature?

    OS: Linux, Debian unstable
    QT Version: 4.1
    Compiler: gcc 4.0.3

    Thanks,
    Ben

  2. #2
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess crashes when deleting it in the finished-handler

    Try this way:
    Qt Code:
    1. process->deleteLater();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Smile Re: QProcess crashes when deleting it in the finished-handler

    Thank you this works!
    It does not crash my application - and I trust it also deletes the object :-)

    Though the question remains, if it is "expected" behaviour that deleting a QProcess in a finish handler results in a crash.

    Thanks again

    Ben

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess crashes when deleting it in the finished-handler

    Yes, it is expected. That's why there is the deleteLater() method To delete objects LATER when current slot processing is finished. When you process a slot and wish to delete the current (emitting or handling) object in it, you should always use deleteLater().

  5. #5
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QProcess crashes when deleting it in the finished-handler

    Thanks again!

Similar Threads

  1. Detect First QProcess finished in a group and kill other
    By Davidaino in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 12:53

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.