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;