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...@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. >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest