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

Koehne Kai Kai.Koehne at digia.com
Thu Nov 15 12:35:21 CET 2012

Hi Xulei,

I'm not at all into this, but could it be that QMessageBox::warning and your ::MessageBox call in MyDll do interfere? Also, is it safe to assume that a call to ::MessageBox actually does something the moment you get DLL_PROCESS_DETACH (which is during application shutdown, after all)? Maybe just find another way to check whether you get DLL_PROCESS_DETACH .



From: interest-bounces+kai.koehne=digia.com at qt-project.org [interest-bounces+kai.koehne=digia.com at qt-project.org] on behalf of Xulei [xulei1981 at 126.com]

Sent: 07 November 2012 03:57

To: interest at qt-project.org

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

Hi All,
I’m developing a project with Qt4.8.3 on Win7/VS2010. I found a critical issue when calling QMessagebox::warning (actually, information(), critical() have the same issue too, but question()
 not). To duplicate the issue according the following steps:
Create a “Qt Application” project (named QtTest) in VS2010 by Qt Add-in with default settings.
Add an action, and call QMessageBox::warning() in its slots.
Create another DLL project (named MyDll) in VS2010, with a single export function (named foo).
Call the exported function “foo” in QtTest project.
Call ::MessageBox of Windows API in “DllMain” of MyDll project to show whether the DllMain with DLL_PROCESS_DETACH is called when program exiting.
Start the QtTest.exe, then exit, the ::MessageBox in DllMain of MyDll will be called.
Start the QtTest.exe, then trigger the action create in step#2, then exit, the MessageBox in DllMain of MyDll will not be called.
Note, the issue may not be duplicate on very PC, I had tested more than 10 PCs, and about half PCs could duplicate this issue.
As you know, when the DLL detach is not called, the other cleanup work won’t work too, such as destructors of local static objects and global objects won’t
 be called.

The URL is the source code I mentioned above.

More information about the Interest mailing list