Quote Originally Posted by jpn View Post
Maybe the problem is with cleaning up the thread(s)? The destructor of the QThread subclass is executed in the thread where the QThread object lives in (usually same thread where it was created in), not in the thread being executed in QThread::run().
This does seem to be what the problem is but I am yet to resolve it. When I click inside the form and then close the application, all threads are exiting correctly. However, when I close the applicaton immediately after launch, the application throws the error and the threads aren't exiting correctly.

If I profile the application using DependencyWalker and close the application immediately after launch I get the following:
Second chance exception 0xC0000008 (Invalid Handle) occurred in "c:\windows\system32\NTDLL.DLL" at address 0x7C90EB74 by thread 30.
Thread 2 exited with code -1073741816 (0xC0000008).
Thread 4 exited with code -1073741816 (0xC0000008).
Thread 1 exited with code -1073741816 (0xC0000008).
Thread 3 exited with code -1073741816 (0xC0000008).
Thread 9 exited with code -1073741816 (0xC0000008).
Thread 11 exited with code -1073741816 (0xC0000008).
Thread 16 exited with code -1073741816 (0xC0000008).
Thread 18 exited with code -1073741816 (0xC0000008).
Thread 24 exited with code -1073741816 (0xC0000008).

However, if I click a widget inside the form before closing, the DependencyWalker log is as follows:
Thread 29 exited with code 0 (0x0).
Thread 27 exited with code 0 (0x0).
Thread 3 exited with code 0 (0x0).
Thread 2 exited with code 0 (0x0).
Thread 30 exited with code 0 (0x0).
Thread 9 exited with code 0 (0x0).
Thread 4 exited with code 0 (0x0).
Thread 24 exited with code 0 (0x0).
Thread 11 exited with code 0 (0x0).
Thread 16 exited with code 0 (0x0).
Thread 18 exited with code 0 (0x0).