| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Using MS Windows, XP, Qt 4.2.3
I am getting a VERY intermittent message from Qt that reads:
"Qt has caught an exception thrown from an event handler....", and this
is always followed by an application lockup which requires a cold boot
of the system.
I have found where this message is generated in the Qt source
(qeventloop.cpp), and in the rest of the message it advises to
"You must reimplement QApplication::notify() and catch all exceptions
there".
So, my question is, I am not sure where the exception is coming from,
though I am pretty sure I know the module that is generating it. Reading
documentation leads me to the installEventFilter function and an
example. Can someone look this over and let me know if you think this
will work (it is hard to debug because the error does not occur often on
my development system, it seems to mostly occur, and then rarely, on
installed systems).
class ExceptionEater : public QObject
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
bool ExceptionEater::eventFilter(QObject *obj, QEvent *event)
{
try
{
return QObject::eventFilter(obj, event);
}
catch(...)
{
qWarning("Exception Eater has caught an exception");
qFatal() << "Exception Eater caught an exception from" <<
obj->objectName();
}
}
I have a custom MsgHandler installed that should write the qFatal
message to a file then quit the app.
It would be nice to get even more information about where the exception
is coming from, I am not sure the dumpObjectInfo will tell me much more.
Any help would be appreciated, due to the intermittent nature of this
problem, it is tough to debug it.
--
[ signature omitted ]
Kenneth Beck wrote:
> Using MS Windows, XP, Qt 4.2.3
> I am getting a VERY intermittent message from Qt that reads:
> "Qt has caught an exception thrown from an event handler....", and this
> is always followed by an application lockup which requires a cold boot
> of the system.
> I have found where this message is generated in the Qt source
> (qeventloop.cpp), and in the rest of the message it advises to
> "You must reimplement QApplication::notify() and catch all exceptions
> there".
> So, my question is, I am not sure where the exception is coming from,
> though I am pretty sure I know the module that is generating it. Reading
> documentation leads me to the installEventFilter function and an
> example. Can someone look this over and let me know if you think this
> will work (it is hard to debug because the error does not occur often on
> my development system, it seems to mostly occur, and then rarely, on
> installed systems).
>
> class ExceptionEater : public QObject
> {
> Q_OBJECT
> protected:
> bool eventFilter(QObject *obj, QEvent *event);
> };
>
> bool ExceptionEater::eventFilter(QObject *obj, QEvent *event)
> {
> try
> {
> return QObject::eventFilter(obj, event);
> }
> catch(...)
> {
> qWarning("Exception Eater has caught an exception");
> qFatal() << "Exception Eater caught an exception from" <<
> obj->objectName();
> }
> }
>
> I have a custom MsgHandler installed that should write the qFatal
> message to a file then quit the app.
>
> It would be nice to get even more information about where the exception
> is coming from, I am not sure the dumpObjectInfo will tell me much more.
>
> Any help would be appreciated, due to the intermittent nature of this
> problem, it is tough to debug it.
This did not seem to work, i tested by throwing an exception from the
module that I think is the culprit.
New solution: re-implement notify in a class that inherits QApplciation:
bool
BIPSApplication::notify ( QObject * receiver, QEvent * event )
{
try
{
return QApplication::notify(receiver,event);
}
catch (...)
{
qWarning("BIPSApplication has caught an exception\nSee file
msghandle.txt for more information");
qDebug() << "BIPSApplication caught an exception from" <<
receiver->objectName() << "from event type" << event->type();
qFatal("Exiting due to exception caught");
}
}
I use this in the main method instead of QApplication.
With my custom MsgHandler installed using qInstallMsgHandler(
myMessageOutput ); in the main() method, the qDebug messages go to an
output file, and the application closes gracefully, using exit() in the
message handler, not abort() as suggested by documentation.
Still, any comments are welcome!
--
[ signature omitted ]
Kenneth Beck wrote: >This did not seem to work, i tested by throwing an exception from the >module that I think is the culprit. Why don't you put your try/catch block around that module then? -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
If your using MS Dev Env, simply turn on stop at all exceptions,
unhandled or not. Under Debug->Exceptions should show you the way.
Scott
> -----Original Message-----
> From: Kenneth Beck [mailto:nekkceb@xxxxxxxxxxx]
> Sent: Sunday, January 06, 2008 9:53 AM
> To: nekkceb@xxxxxxxxxxx; qt-interest@xxxxxxxxxxxxx
> Subject: Re: Trapping exceptions
>
> Kenneth Beck wrote:
> > Using MS Windows, XP, Qt 4.2.3
> > I am getting a VERY intermittent message from Qt that reads:
> > "Qt has caught an exception thrown from an event handler....", and
this
> > is always followed by an application lockup which requires a cold
boot
> > of the system.
> > I have found where this message is generated in the Qt source
> > (qeventloop.cpp), and in the rest of the message it advises to
> > "You must reimplement QApplication::notify() and catch all
exceptions
> > there".
> > So, my question is, I am not sure where the exception is coming
from,
> > though I am pretty sure I know the module that is generating it.
Reading
> > documentation leads me to the installEventFilter function and an
> > example. Can someone look this over and let me know if you think
this
> > will work (it is hard to debug because the error does not occur
often on
> > my development system, it seems to mostly occur, and then rarely, on
> > installed systems).
> >
> > class ExceptionEater : public QObject
> > {
> > Q_OBJECT
> > protected:
> > bool eventFilter(QObject *obj, QEvent *event);
> > };
> >
> > bool ExceptionEater::eventFilter(QObject *obj, QEvent *event)
> > {
> > try
> > {
> > return QObject::eventFilter(obj, event);
> > }
> > catch(...)
> > {
> > qWarning("Exception Eater has caught an exception");
> > qFatal() << "Exception Eater caught an exception from" <<
> > obj->objectName();
> > }
> > }
> >
> > I have a custom MsgHandler installed that should write the qFatal
> > message to a file then quit the app.
> >
> > It would be nice to get even more information about where the
exception
> > is coming from, I am not sure the dumpObjectInfo will tell me much
more.
> >
> > Any help would be appreciated, due to the intermittent nature of
this
> > problem, it is tough to debug it.
> This did not seem to work, i tested by throwing an exception from the
> module that I think is the culprit.
> New solution: re-implement notify in a class that inherits
QApplciation:
> bool
> BIPSApplication::notify ( QObject * receiver, QEvent * event )
> {
> try
> {
> return QApplication::notify(receiver,event);
> }
> catch (...)
> {
> qWarning("BIPSApplication has caught an exception\nSee file
> msghandle.txt for more information");
> qDebug() << "BIPSApplication caught an exception from" <<
> receiver->objectName() << "from event type" << event->type();
> qFatal("Exiting due to exception caught");
> }
> }
>
> I use this in the main method instead of QApplication.
>
> With my custom MsgHandler installed using qInstallMsgHandler(
> myMessageOutput ); in the main() method, the qDebug messages go to an
> output file, and the application closes gracefully, using exit() in
the
> message handler, not abort() as suggested by documentation.
>
> Still, any comments are welcome!
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Scott Aron Bloom wrote: > If your using MS Dev Env, simply turn on stop at all exceptions, > unhandled or not. Under Debug->Exceptions should show you the way. > > Scott > Thanks for the suggestion, but the crash always happens on systems where the debugger is not working. I think I got the problem licked, basically followed the instructions in documentation (for once!). -- [ signature omitted ]