[Qt-jambi-interest] Crash on System.exit()

Eskil Abrahamsen Blomfeldt eblomfel at trolltech.com
Mon Feb 9 11:36:38 CET 2009


Mathias wrote:
> actually in my example case the exception happened during the 
> application startup, before the call to QApplication.exec().
> According to the documentation QApplication.exit() does nothing, when 
> the event loop is not started yet.

Ok, sorry, I was confused by the optional invokeLater() in your code. 
Just so you know, invokeLater() only works if you are running an event 
loop in the main thread.

> However, I did find the cause for the crash.
> One of the first things my app does is install a QMessageHandler with 
> QMessageHandler.installMessageHandler(...), to properly log some of the 
> Jambi errors.
> If I call System.exit() without having unregistered the installed 
> QMessageHandler with QMessageHandler.removeMessageHandler(...) Jambi 
> crashes. If I remove the handler before the System.exit() call the 
> shutdown is completed nicely.

I'll look into this. That doesn't sound like it should crash =)

> 
> Well, actually not quite... :)
> No seg fault anymore, just the following message at the very end:
> QObject::killTimers: timers cannot be stopped from another thread

We recommend running an event loop, but if you are unable to do so, 
manually disposing of the QApplication will clean up for you and you 
should avoid the warnings. The warnings are there to alert you that the 
QApplication is not being properly shut down, so it is unable to perform 
its cleanup code.

Like this:

public class SystemExit {

     public static void main(String args[]) {
         QApplication.initialize(args);

         QMessageBox.critical(null, "error", "error");
         QApplication.instance().dispose();
         System.exit(1);
     }

}


-- Eskil



More information about the Qt-jambi-interest mailing list