Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
4.7.2
-
None
-
Windows / Visual Studio 2008 / 2010 / 2005
Description
The code snippet below is enough to reproduce this, when built with a static build of Qt.
#include <QDebug> struct MyStruct { ~MyStruct() { qWarning("Warning from destructor"); } }mystruct; int main(int argc, char *argv[]) { qDebug("Here in main()"); return 0; }
Since the static QtMsgHandler handler variable's destructor has already been called as a result of mystruct going out of scope or qDebug() being called an exception is thrown as there is no guarantee about the order in which this happens.
If a shared version of Qt is used, the static variable QtMsgHandler handler stays valid as the static variables are not destroyed as soon as an object that is using them goes out of scope.