[Development] Allowing event delivery prior to and after QCoreApplication

Julien Cugnière julien.cugniere at gmail.com
Wed Apr 15 15:01:29 CEST 2015


2015-04-14 20:39 GMT+02:00 Thiago Macieira <thiago.macieira at intel.com>:
>
> We removed the try/catch and replaced with stack objects that will unwind
> properly. If you're lucky, an exception will simply unwind QCoreApplication
> out of exec(), so a try/catch around exec() may work.
>
> But this is untested and unsupported. DO NOT throw through the event loop and
> DO NOT throw back to the signal-slot delivery mechanism. We will not deal with
> bug reports that this does not work. I may accept patches that fix this,
> provided they don't introduce performance issues.
>

So just to make sure I understand it correctly, the following :

    bool SomeApplication::notify(QObject *object, QEvent *event)
    {
        try {
            return QCoreApplication::notify(object, event);
        }
        catch (const Exception& e) {
            writeLog(e.message());
            return true;
        }
    }

Works for the moment (we use with Qt 5.3 just fine), but is not
supported anymore, and has no official replacement. And with your
change, it will stop working entirely. Any application relying on this
will have to either add hundreds of thousands of try/catch all over
the place (in all slots and event handlers, very error-prone), or be
redesigned from scratch to not use exceptions.

For the software we develop at work, we will probably end up patching
our copy of Qt, as rewriting everything will be prohibitive, and we
don't need QtDBUS, or post-application event delivery.



More information about the Development mailing list