[Interest] calling QMessageBox::warning() may break the DLL detaching on VS2010

Andrew Xu xulei.js at gmail.com
Fri Nov 16 02:49:17 CET 2012

Hi All,

I'm the author of this thread. Because I didn't receive the confirmation
mail using 126.com mailbox, I changed to gmail mailbox.

Seems the ::MessageBox comfused us, ok, forget it please.

I found the issue when a destructor of a local static object wasn't called
when my first Qt program exiting after calling QMessageBox::warning(). If I
didn't called QMessageBox::warning(), the destructor was called normally.

I modified the demo program. explain it here.

1.       Create a “Qt Application” project (named QtTest) in VS2010 by Qt
Add-in with default settings.

2.       Add an action, and call QMessageBox::warning() in its slots.

3.       Create another DLL project (named MyDll) in VS2010, with a single
export function (named foo).

class MyObj
    ~MyObj() {
        printf("destructor called.\n");

    void test() {
        printf("test() called\n");

void foo()
    static MyObj obj;

4.       Call the exported function “foo()” in QtTest project.

     QtTest::QtTest(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)

    // foo is exported in MyDll.dll, to make sure MyDll.dll is loaded
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121116/be3756ae/attachment.html>

More information about the Interest mailing list