Quote Originally Posted by jpn View Post
Run the application in VS in debug mode, break it when the exception is thrown, and see the call stack (Debug->Windows->Call Stack). It should help you find the actual problem.
I looked at this already. Here is the call stack after the exception is thrown.
ntdll.dll!7c90eb74()
ntdll.dll!7c90eb74()
> QtCored4.dll!QBasicAtomic::testAndSetRelease(int expected=1, int newval=0) Line 99 + 0x18 C++
QtCored4.dll!QMutex::unlock() Line 250 + 0xe C++
QtCored4.dll!qt_adopted_thread_watcher_function(vo id * __formal=0x1020301f) Line 152 C++
01fcffb4()
ntdll.dll!7c91b298()
kernel32.dll!7c80b683()
ntdll.dll!7c91b298()

Quote Originally Posted by Mike View Post
I had the problem when using QMainWindow->setAttribute(Qt::WA_DeleteOnClose); I did remove that from my code, and now the application terminates without exception.
My main() function creates the MainWindow on the stack and no attributes are currently being set.

It looks like one of the custom widgets on the form doesn't seem to get shutdown properly. The mysterious thing is why it works as expected when I click the widgets on the form before closing the MainWindow but it throws the exception when I close the MainWindow immediately after launch without clicking any widgets.