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

Eskil Abrahamsen Blomfeldt eblomfel at trolltech.com
Mon Feb 9 10:46:57 CET 2009


Mathias wrote:
> Everything works as expected except for the seg fault at the very end 
> (see attachment).
> 
> Am I missing a crucial clean up step before the System.exit() ?

When you use System.exit() you aren't letting QApplication clean up its 
resources properly. Could you try using QApplication.exit() instead? If 
you need to return an exit code from your process, you could do 
something like this:

import com.trolltech.qt.gui.*;

public class SystemExit {


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

         QApplication.invokeLater(new Runnable() {
             public void run() {
                 QMessageBox.critical(null, "error", "error");
                 QApplication.exit(1);
             }
         });

         int err = QApplication.exec();
         System.exit(err);
     }

}


-- Eskil



More information about the Qt-jambi-interest mailing list