path: root/src/plugins/platforms/windows/qwindowstheme.h
diff options
authorGabriel de Dietrich <>2016-11-22 18:43:28 -0800
committerGabriel de Dietrich <>2016-12-21 19:15:41 +0000
commite1113cae9865850bd8f5bc7f1331027e07ce1e49 (patch)
treef6f6135931ee3541626da59061d5a6502b43bd95 /src/plugins/platforms/windows/qwindowstheme.h
parent39e64e798fdf5f6476b4fe863d017ca1b9ff582f (diff)
QWindowsTheme: Run dedicated SHGetFileInfo() thread
The changes are motivated by the following reasons: 1. SHGetFileInfo() needs to be COM-intialized per thread. Microsoft's documentation for CoInitalizeEx() is quite unambiguous about this. 2. Following point 1, using a thread from the global thread pool means we would taint every such thread with the COM-initialization state. This may result in unexpected behavior in other parts of the application. Moreover, systematic COM-uninitialization can be expensive and can't be recommended in this case. 3. Even though the timeout duration is pretty generous, the logic is wrong and could lead to serious errors should the call to SHGetFileInfo() actually take too long. This is because we let the thread run with references to the main thread's stack, namely a reference to the file name string, and pointers to the result variable and SHFILEINFO struct. Running a dedicated thread allows us to ensure points 1 and 2. Point 3 is ensured by making a local copy of the file name and using local instances for the info struct and the result. Then, provided the thread has not been cancelled, we can copy the info and result values back into the main thread's stack referenced memory areas. This also removes all need for QWindowsThreadPoolRunner which will remain in the code base nonetheless. Change-Id: Ic9c2d6204ac015aa409db2b57a09837361203291 Reviewed-by: Friedemann Kleint <> Reviewed-by: Andy Shaw <>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowstheme.h')
1 files changed, 0 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index 15b627cce0..a3019ff6eb 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -40,7 +40,6 @@
-#include "qwindowsthreadpoolrunner.h"
#include <qpa/qplatformtheme.h>
#include <QtCore/QSharedPointer>
@@ -88,7 +87,6 @@ private:
static QWindowsTheme *m_instance;
QPalette *m_palettes[NPalettes];
QFont *m_fonts[NFonts];
- const QSharedPointer<QWindowsThreadPoolRunner> m_threadPoolRunner;
QList<QSize> m_fileIconSizes;