[Qt-interest] try-catch in QApplication::notify() reimplementation
Malyushytsky, Alex
alex at wai.com
Thu Aug 5 23:29:31 CEST 2010
Virtual functions does not have to have "virtual" keword in the derived classes.
So notify is virtual, check:
bool QCoreApplication::notify ( QObject * receiver, QEvent * event ) [virtual]
Alex
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Karl Krach
Sent: Thursday, August 05, 2010 6:18 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] try-catch in QApplication::notify() reimplementation
Hello,
I have a short question. I'm just wondering, how "You must reimplement
QApplication::notify() and catch all exceptions there." could work.
I ve implemented the following, and many mailinglist posts recommend the same,
but it's not working:
class MyApplication : public QApplication
{
public:
MyApplication(int argc, char** argv) : QApplication(argc, argv) {}
virtual ~MyApplication() {}
virtual bool nofity(QObject *rec, QEvent *ev)
{
qDebug() << "MyApplication::nofity";
try {
return QApplication::notify(rec, ev);
}
catch( ... ) {
qDebug() << "Unknown Exception: Terminating!";
exit(0);
}
return false;
}
};
I ve set a breakpoint on the "throw MyException()" statement, and this is the
stack trace. I'm wondering, why on #7 not MyApplication::notify() is called.
Thread 2 (Thread 0xb69d6b70 (LWP 10535)):
#0 ExceptionHandler::ThrowException (this=0x8086d50) at
exceptionhandler.cpp:29
[...]
#5 0xb7670b6c in QApplicationPrivate::notify_helper (this=0x8051978,
receiver=0x8086d50, e=0x80c14f0) at kernel/qapplication.cpp:4389
#6 0xb7677aae in QApplication::notify (this=0xbffff408, receiver=0x8086d50,
e=0x80c14f0) at kernel/qapplication.cpp:3791
#7 0xb72e73ab in QCoreApplication::notifyInternal (this=0xbffff408,
receiver=0x8086d50, event=0x80c14f0) at kernel/qcoreapplication.cpp:732
#8 0xb72e99fb in QCoreApplication::sendEvent (receiver=0x0, event_type=0,
data=0x80895e8) at kernel/qcoreapplication.h:215
[...]
Maybe it's a problem, that QApplication::notify() is not virtual - but
according the git repro it was since 4.5 never virtual... :s
Thanks a lot,
Charly
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list