Very simple application crashes under Linux 64 bit (Ubuntu 11.10 and 12.04)
The following very simple code crashes in release mode under Linux 64 bit (tested on 3 different PCs running Ubuntu 11.10 and 12.04, Qt version 4.7.4 and 4.8.0). When the QApplication instance is moved outside of the AppServer class then it does not crash:
@TEMPLATE = app
TARGET = testapp
CONFIG += release
HEADERS += appserver.h
SOURCES += main.cpp appserver.cpp
int main(int argc, char** argv)
AppServer app(argc, argv);
QMessageBox::warning(NULL, "test", "test");
AppServer(int argc, char** argv);
#endif // APPSERVER_H
AppServer::AppServer(int argc, char** argv)
: app_(argc, argv)
I would guess it's probably crashing because the QApplication is private to AppServer, and as such, the QMessageBox (outside the scope of AppServer) has trouble has a problem with that.
What's the reasoning of making QApplication a member of AppServer? If it really needs to be tightly coupled, you could perhaps subclass it, instead.
The signature of the AppServer constructor is wrong. You must have an int reference:
AppServer(int &argc, char** argv);
It is stated in the docs.
Putting QApplication as private member into the class is nonsense. You can get a pointer to that instance always and everywhere by calling QApplication::instance().
Thanks; the argc reference was indeed the case - missed it.