From e1113cae9865850bd8f5bc7f1331027e07ce1e49 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 22 Nov 2016 18:43:28 -0800 Subject: 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 --- src/plugins/platforms/windows/qwindowstheme.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowstheme.h') 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 @@ #ifndef QWINDOWSTHEME_H #define QWINDOWSTHEME_H -#include "qwindowsthreadpoolrunner.h" #include #include @@ -88,7 +87,6 @@ private: static QWindowsTheme *m_instance; QPalette *m_palettes[NPalettes]; QFont *m_fonts[NFonts]; - const QSharedPointer m_threadPoolRunner; QList m_fileIconSizes; }; -- cgit v1.2.3