[Interest] calling QMessageBox::warning() may break the DLL detaching on VS2010
Andrew Xu
xulei.js at gmail.com
Fri Nov 16 03:05:29 CET 2012
Sorry, the previous mail is not complete. continue...
5. As you see , there is a static local object in the foo(), the destructor
of MyObj should be called when the program exiting.
1) If the QMessageBox::warning() were no't called, the desctructor of
MyObj will be called normally.
2) *If the QMessageBox::warning() were called before the program
exiting, the destructor of MyObj won't be called. It's ridiculous, isn't it?
*
By the way, I checked whether the destructor is called or not by set a
breakpoint.
The link the source code of the demo.
https://dl.dropbox.com/u/60152607/QtTest.7z
Thanks,
Andrew
2012/11/16 Andrew Xu <xulei.js at gmail.com>
> 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
> {
> public:
> ~MyObj() {
> printf("destructor called.\n");
> }
>
> void test() {
> printf("test() called\n");
> }
> };
>
>
> void foo()
> {
> static MyObj obj;
> obj.test();
> }
>
> 4. Call the exported function “foo()” in QtTest project.
>
> QtTest::QtTest(QWidget *parent, Qt::WFlags flags)
> : QMainWindow(parent, flags)
> {
> ui.setupUi(this);
>
> // foo is exported in MyDll.dll, to make sure MyDll.dll is loaded
> foo();
> }
> 5.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121116/fb28832d/attachment.html>
More information about the Interest
mailing list