[Interest] Slot exception being thrown on exit

Thiago Macieira thiago.macieira at intel.com
Wed Mar 14 05:04:03 CET 2018


On Tuesday, 13 March 2018 19:08:00 PDT Ramakanth Kesireddy wrote:
> new Application ( argc
>                                 , argv
>                                 , Application::GuiServer );

There are two problems in the above line. Not fatal, but they are worrisome.

First, "new Application" is probably wrong. Create it on the stack. If your 
application has a problem with that, then redesign so that the problem goes 
away. The class deriving from QCoreApplication is supposed to be created in 
main(), be the first QObject created and the last destroyed. If you're using 
new, you're probably trying to make it outlive the function it's created in, 
which is weird.

Second, what is that third parameter? QApplication has a hidden third 
parameter which is a failed attempt at determining the Qt version to be 
compatible with. But you should not be passing anything to it. Your 
Application class doesn't use the parameter it receives either.

> Qt has caught an exception thrown from an event handler. Throwing
> exceptions from an event handler is not supported in Qt. You must
> reimplement QApplication::notify() and catch all exceptions there.
> 
> Though it works as expected in a sample app, still unable to find the
> rootcause.
> Please suggest in this regard.

Put a breakpoint in the throw function. If you're using GCC or Clang, it's 
__cxa_throw.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center






More information about the Interest mailing list