Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.2.1
-
None
-
Windows 7, Visual Studio 2012, Win32 debug and release
-
feda990ae8fa3bc25ad5b5b7f7cc4733137519d6 (branch 5.3, 19.6.2014, fix version 5.3.2)
Description
Creating and deleting a class derived from QThread with a started Event Queue (QThread::exec() inside run()) lead to spurious internal window 1407 warnings issued by CreateWindow inside qtbase/src/corelib/kernal/qeventdispatcher_win.cpp static HWND qt_create_internal_window.
Digging further into the code reveiled that RegisterClass and UnregisterClass error codes are not properly evaluated. The lazy deletion of the event dispatcher caused that the destructor call of the previous created threads unregistered the class right between the call of RegisterClass and CreateWindow inside qt_create_internal_window. This in turn lead to the error 1407.
The following lines of code are involved (qtbase/src/corelib/kernal/qeventdispatcher_win.cpp):
1.) static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher)
RegisterClass(&wc);
which could be changed into
ATOM res = RegisterClass(&wc); if (res == 0) { qWarning("QEventDispatcher: RegisterClass Failed: %d\n", (int)GetLastError()); }
Note that CreateWindow on unsucessful register will cause an error code of 1407.
2.) QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
UnregisterClass((wchar_t*)className.utf16(), qWinAppInst());
which could be changed into
BOOL res = UnregisterClass((wchar_t*)className.utf16(), qWinAppInst()); if (!res) { qWarning("QEventDispatcher: UnregisterClass Failed: %d\n", (int)GetLastError()); }
I could fix this issue for myself by an aggregational rather then derivational use of QThread. However the cloaking of the error codes of RegisterClass and UnregisterClass made the debugging process rather tedious.
Despite of this, thanks for the great work of the Qt project!
Best,
Christian