From e40b13459bb382732c1f0349bd1274b9ba55078b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 May 2012 09:11:13 +0200 Subject: Windows: Fix Vista style for use with QProxyStyle. Cleanup the treeview helper window in case XP style cleans the handle map. This fixes the drawing of the PE_IndicatorBranch primitives in Qt Creator. Task-number: QTBUG-25395 Change-Id: Iba561709e3d4032a59690c7b9163fb69bfa98619 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qwindowsvistastyle.cpp | 18 +++++++++++++++--- src/widgets/styles/qwindowsvistastyle_p.h | 1 + src/widgets/styles/qwindowsxpstyle_p.h | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 138f5dbf17..6fce426dd3 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -2469,7 +2469,12 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) { QWindowsXPStyle::unpolish(widget); - QWindowsVistaStylePrivate *d = const_cast(d_func()); + QWindowsVistaStylePrivate *d = d_func(); + // Delete the tree view helper in case the XP style cleaned the + // theme handle map due to a theme or QStyle change (QProxyStyle). + if (!QWindowsXPStylePrivate::hasTheme(QWindowsXPStylePrivate::TreeViewTheme)) + d->cleanupTreeViewTheming(); + d->stopAnimation(widget); #ifndef QT_NO_LINEEDIT @@ -2542,8 +2547,7 @@ QWindowsVistaStylePrivate::QWindowsVistaStylePrivate() : QWindowsVistaStylePrivate::~QWindowsVistaStylePrivate() { qDeleteAll(animations); - if (m_treeViewHelper) - DestroyWindow(m_treeViewHelper); + cleanupTreeViewTheming(); } void QWindowsVistaStylePrivate::timerEvent() @@ -2694,6 +2698,14 @@ bool QWindowsVistaStylePrivate::initTreeViewTheming() return QWindowsXPStylePrivate::createTheme(QWindowsXPStylePrivate::TreeViewTheme, m_treeViewHelper); } +void QWindowsVistaStylePrivate::cleanupTreeViewTheming() +{ + if (m_treeViewHelper) { + DestroyWindow(m_treeViewHelper); + m_treeViewHelper = 0; + } +} + /*! \internal */ diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h index 78282d01ef..cdb1227319 100644 --- a/src/widgets/styles/qwindowsvistastyle_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p.h @@ -208,6 +208,7 @@ public: private: bool initTreeViewTheming(); + void cleanupTreeViewTheming(); QList animations; QBasicTimer animationTimer; diff --git a/src/widgets/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h index 058668d3fb..1ef60096c7 100644 --- a/src/widgets/styles/qwindowsxpstyle_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p.h @@ -351,6 +351,7 @@ public: static HTHEME createTheme(int theme, HWND hwnd); static QString themeName(int theme); + static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; } QIcon dockFloat, dockClose; -- cgit v1.2.3