Qt-jambi-interest Archive, March 2007
VM crash when quit from extended QApplication
Message 1 in thread
Hello!
On qtjambi-linux-beta-1.0.0 I have folowing error message at exit, after
click on button "btn" (see the source bellow):
# SIGSEGV (0xb) at pc=0xb0875ebc, pid=11603, tid=2991451056
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_10-b03 mixed mode, sharing)
# Problematic frame:
# C [libqtjambi.so+0x16ebc] _Z18qtjambi_find_classP7JNIEnv_PKc+0x2c
public class Application extends QApplication
{
public static Application _instance;
public Application(String[] args)
{
super(args);
}
public static void initialize(String[] args)
{
if (_instance == null)
_instance = new Application(args);
}
public static Application instance() { return _instance; }
public static void main(String[] args)
{
Application.initialize(args);
QPushButton btn = new QPushButton();
btn.clicked.connect(Application.instance(), "quit()");
btn.show();
System.exit(Application.exec());
}
}
Is this code buggy?
--
[ signature omitted ]
Message 2 in thread
Feoktistov Andrey wrote:
>Hello!
>
>On qtjambi-linux-beta-1.0.0 I have folowing error message at exit, after
>click on button "btn" (see the source bellow):
>
>
Hi, Feoktistov.
This is an ufortunate result of Qt Jambi attempting to clean up some
global static data in the process shut down code. We are looking into
the problem, but currently you will have to manually dispose your
Application instance before exiting the application.
This is only an issue when you subclass QApplication, because
QApplication.initialize() will take care of this for you.
Here are two suggestions to how you can avoid the crash:
>
>
> public static void main(String[] args)
> {
> Application.initialize(args);
>
> QPushButton btn = new QPushButton();
> btn.clicked.connect(Application.instance(), "quit()");
>
>
You can either connect the applications "aboutToQuit" signal to the
dispose method:
Application.instance().aboutToQuit.connect(Application.instance(),
"dispose()");
> btn.show();
>
> System.exit(Application.exec());
>
>
Or, simpler: You can explicitly dispose the instance when the event loop
has terminated:
int code = Application.exec();
Application.instance().dispose();
System.exit(code);
Hopefully either of these should prevent the application to crash on
shut down.
-- Eskil