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:
Code:
#0 0xb748809d in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
#1 0xb7488a2c in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
#2 0xb74341ea in QProcess::finished () from /usr/lib/libQtCore_debug.so.4
#3 0xb743559f in QProcessPrivate::processDied () from /usr/lib/libQtCore_debug.so.4
#4 0xb7435686 in QProcess::qt_metacall () from /usr/lib/libQtCore_debug.so.4
#5 0xb74885b1 in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
#6 0xb7488a2c in QMetaObject::activate () from /usr/lib/libQtCore_debug.so.4
#7 0xb74a6241 in QSocketNotifier::activated () from /usr/lib/libQtCore_debug.so.4
#8 0xb7490e22 in QSocketNotifier::event () from /usr/lib/libQtCore_debug.so.4
#9 0xb75cc8b4 in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui_debug.so.4
#10 0xb75cd8c9 in QApplication::notify () from /usr/lib/libQtGui_debug.so.4
#11 0xb749b899 in QEventDispatcherUNIX::activateSocketNotifiers () from /usr/lib/libQtCore_debug.so.4
#12 0xb749c506 in QEventDispatcherUNIXPrivate::doSelect () from /usr/lib/libQtCore_debug.so.4
#13 0xb749d06b in QEventDispatcherUNIX::processEvents () from /usr/lib/libQtCore_debug.so.4
#14 0xb76348e7 in QEventDispatcherX11::processEvents () from /usr/lib/libQtGui_debug.so.4
#15 0xb7479a24 in QEventLoop::processEvents () from /usr/lib/libQtCore_debug.so.4
#16 0xb7479c76 in QEventLoop::exec () from /usr/lib/libQtCore_debug.so.4
#17 0xb747c611 in QCoreApplication::exec () from /usr/lib/libQtCore_debug.so.4
#18 0xb75cc5d7 in QApplication::exec () from /usr/lib/libQtGui_debug.so.4
#19 0x0808c857 in main (argc=1, argv=0xbfb40004) at main.cpp:79
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
Re: QProcess crashes when deleting it in the finished-handler
Try this way:
Code:
process->deleteLater();
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
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().
Re: QProcess crashes when deleting it in the finished-handler