Qt-jambi-interest Archive, October 2007
Problem running Qt Jambi on Mac OS X Leopard
Message 1 in thread
Hi,
HelloWorld crash without any message, but with Java exit code 1.
public class HelloWorld {
public static void main(String args[]) {
QApplication.initialize(args);
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
hello.setWindowTitle("Hello World");
hello.show();
QApplication.exec();
}
}
If I change the class ...
public class HelloWorld extends QWidget {
public static void main(String args[]) {
QApplication.initialize(args);
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
hello.setWindowTitle("Hello World");
hello.show();
QApplication.exec();
}
}
... I read a warning and Exception, but application start.
WARNING: QApplication was not created in the main() thread.
java.lang.NullPointerException
at com.trolltech.qt.Utilities.unpackPlugins(Utilities.java:405)
at
com.trolltech.qt.gui.QApplication.initialize(QApplication.java:465)
at de.muspellheim.jerp.HelloWorld.main(HelloWorld.java:23)
Falko.
Message 2 in thread
Falko Schumann wrote:
> Hi,
>
> HelloWorld crash without any message, but with Java exit code 1.
>
...
> WARNING: QApplication was not created in the main() thread.
> java.lang.NullPointerException
> at
> com.trolltech.qt.Utilities.unpackPlugins(Utilities.java:405)
> at
> com.trolltech.qt.gui.QApplication.initialize(QApplication.java:465)
> at de.muspellheim.jerp.HelloWorld.main(HelloWorld.java:23)
Hi Falko,
Did you start java with -XstartOnFirstThread, e.g.
> java -XstartOnFirstThread com.trolltech.launcher.Launcher
Qt on Mac OS X requires that QApplication is initialized in the process'
main thread. The virtual machines on the other platforms will call
main() in the process main thread, but on Mac OS X it will call it on a
different thread. For this reason, you need the startOnFirstThread
option to the virtual machine. I'm investigating if there is nice way to
throw a warning about this rather than to crash.
best regards,
Gunnar
Message 3 in thread
Falko Schumann wrote:
> Hi Gunnar,
>
> yes, I started with this option. I programm with Qt since 2 years, very
> successfully under Tiger ;-)
>
> Try to instance QWidget ( new QWidget(null) ) before
> QApplication.initialize() has no effect. Java crashs with exit code 1.
>
> But it's not important to use QWidget extending the application. It
> works also with QObject, QVariant etc.
Hi Falko,
From the original "QApplication not started on main thread()" message I
assumed you had forgotten the "-XstartOnFirstThread".
After some testing on a Leopard machine, I can confirm that there are
some oddities there. I haven't been quite able to reproduce the crash
yet, but I did see strange error messages. I'll look more into it and
see what I can find.
-
Gunnar