Cleanup of QWindowsVistaStyle.
- Remove the limbowidget, try to obtain HWND from a toplevel or the desktop instead. - Clean up handling of the theme map, avoid operator[] and repeated invocation of of map.end() Change-Id: Ic5ea6186508f37aaff782ca304ce577899f7b41c Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com>
This commit is contained in:
parent
71db6d654e
commit
d39d8b49d5
@ -159,14 +159,14 @@ HTHEME XPThemeData::handle()
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!htheme && QWindowsXPStylePrivate::handleMap)
|
if (!htheme && QWindowsXPStylePrivate::handleMap)
|
||||||
htheme = QWindowsXPStylePrivate::handleMap->operator[](name);
|
htheme = QWindowsXPStylePrivate::handleMap->value(name);
|
||||||
|
|
||||||
if (!htheme) {
|
if (!htheme) {
|
||||||
htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), (wchar_t*)name.utf16());
|
htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), (wchar_t*)name.utf16());
|
||||||
if (htheme) {
|
if (htheme) {
|
||||||
if (!QWindowsXPStylePrivate::handleMap)
|
if (!QWindowsXPStylePrivate::handleMap)
|
||||||
QWindowsXPStylePrivate::handleMap = new QMap<QString, HTHEME>;
|
QWindowsXPStylePrivate::handleMap = new QWindowsXPStylePrivate::ThemeHandleMap;
|
||||||
QWindowsXPStylePrivate::handleMap->operator[](name) = htheme;
|
QWindowsXPStylePrivate::handleMap->insert(name, htheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,6 @@ HRGN XPThemeData::mask(QWidget *widget)
|
|||||||
|
|
||||||
// QWindowsXPStylePrivate -------------------------------------------------------------------------
|
// QWindowsXPStylePrivate -------------------------------------------------------------------------
|
||||||
// Static initializations
|
// Static initializations
|
||||||
QWidget *QWindowsXPStylePrivate::limboWidget = 0;
|
|
||||||
QPixmap *QWindowsXPStylePrivate::tabbody = 0;
|
QPixmap *QWindowsXPStylePrivate::tabbody = 0;
|
||||||
QMap<QString,HTHEME> *QWindowsXPStylePrivate::handleMap = 0;
|
QMap<QString,HTHEME> *QWindowsXPStylePrivate::handleMap = 0;
|
||||||
bool QWindowsXPStylePrivate::use_xp = false;
|
bool QWindowsXPStylePrivate::use_xp = false;
|
||||||
@ -289,14 +288,7 @@ void QWindowsXPStylePrivate::cleanup(bool force)
|
|||||||
|
|
||||||
use_xp = false;
|
use_xp = false;
|
||||||
cleanupHandleMap();
|
cleanupHandleMap();
|
||||||
if (limboWidget) {
|
|
||||||
if (QApplication::closingDown())
|
|
||||||
delete limboWidget;
|
|
||||||
else
|
|
||||||
limboWidget->deleteLater();
|
|
||||||
}
|
|
||||||
delete tabbody;
|
delete tabbody;
|
||||||
limboWidget = 0;
|
|
||||||
tabbody = 0;
|
tabbody = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,11 +299,13 @@ void QWindowsXPStylePrivate::cleanup(bool force)
|
|||||||
*/
|
*/
|
||||||
void QWindowsXPStylePrivate::cleanupHandleMap()
|
void QWindowsXPStylePrivate::cleanupHandleMap()
|
||||||
{
|
{
|
||||||
|
typedef ThemeHandleMap::const_iterator ConstIterator;
|
||||||
|
|
||||||
if (!handleMap)
|
if (!handleMap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMap<QString, HTHEME>::Iterator it;
|
const ConstIterator cend = handleMap->constEnd();
|
||||||
for (it = handleMap->begin(); it != handleMap->end(); ++it)
|
for (ConstIterator it = handleMap->constBegin(); it != cend; ++it)
|
||||||
pCloseThemeData(it.value());
|
pCloseThemeData(it.value());
|
||||||
delete handleMap;
|
delete handleMap;
|
||||||
handleMap = 0;
|
handleMap = 0;
|
||||||
@ -325,20 +319,22 @@ void QWindowsXPStylePrivate::cleanupHandleMap()
|
|||||||
*/
|
*/
|
||||||
HWND QWindowsXPStylePrivate::winId(const QWidget *widget)
|
HWND QWindowsXPStylePrivate::winId(const QWidget *widget)
|
||||||
{
|
{
|
||||||
if (widget && widget->internalWinId()) {
|
if (widget)
|
||||||
QWidget *w = const_cast<QWidget *>(widget);
|
if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(const_cast<QWidget *>(widget)))
|
||||||
return QApplicationPrivate::getHWNDForWidget(w);
|
return hwnd;
|
||||||
}
|
|
||||||
if (!limboWidget) {
|
|
||||||
limboWidget = new QWidget(0);
|
|
||||||
limboWidget->createWinId();
|
|
||||||
limboWidget->setObjectName(QLatin1String("xp_limbo_widget"));
|
|
||||||
// We don't need this internal widget to appear in QApplication::topLevelWidgets()
|
|
||||||
if (QWidgetPrivate::allWidgets)
|
|
||||||
QWidgetPrivate::allWidgets->remove(limboWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
return QApplicationPrivate::getHWNDForWidget(limboWidget);
|
const QWidgetList toplevels = QApplication::topLevelWidgets();
|
||||||
|
if (!toplevels.isEmpty())
|
||||||
|
if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevels.front()))
|
||||||
|
return topLevelHwnd;
|
||||||
|
|
||||||
|
if (QDesktopWidget *desktop = qApp->desktop())
|
||||||
|
if (const HWND desktopHwnd = QApplicationPrivate::getHWNDForWidget(desktop))
|
||||||
|
return desktopHwnd;
|
||||||
|
|
||||||
|
Q_ASSERT(false);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \internal
|
/*! \internal
|
||||||
|
@ -286,6 +286,8 @@ class QWindowsXPStylePrivate : public QWindowsStylePrivate
|
|||||||
{
|
{
|
||||||
Q_DECLARE_PUBLIC(QWindowsXPStyle)
|
Q_DECLARE_PUBLIC(QWindowsXPStyle)
|
||||||
public:
|
public:
|
||||||
|
typedef QMap<QString, HTHEME> ThemeHandleMap;
|
||||||
|
|
||||||
QWindowsXPStylePrivate()
|
QWindowsXPStylePrivate()
|
||||||
: QWindowsStylePrivate(), hasInitColors(false), bufferDC(0), bufferBitmap(0), nullBitmap(0),
|
: QWindowsStylePrivate(), hasInitColors(false), bufferDC(0), bufferBitmap(0), nullBitmap(0),
|
||||||
bufferPixels(0), bufferW(0), bufferH(0)
|
bufferPixels(0), bufferW(0), bufferH(0)
|
||||||
@ -326,7 +328,7 @@ public:
|
|||||||
QRgb sliderTickColor;
|
QRgb sliderTickColor;
|
||||||
bool hasInitColors;
|
bool hasInitColors;
|
||||||
|
|
||||||
static QMap<QString,HTHEME> *handleMap;
|
static ThemeHandleMap *handleMap;
|
||||||
|
|
||||||
QIcon dockFloat, dockClose;
|
QIcon dockFloat, dockClose;
|
||||||
|
|
||||||
@ -338,7 +340,6 @@ private:
|
|||||||
|
|
||||||
static QBasicAtomicInt ref;
|
static QBasicAtomicInt ref;
|
||||||
static bool use_xp;
|
static bool use_xp;
|
||||||
static QWidget *limboWidget;
|
|
||||||
static QPixmap *tabbody;
|
static QPixmap *tabbody;
|
||||||
|
|
||||||
QHash<ThemeMapKey, ThemeMapData> alphaCache;
|
QHash<ThemeMapKey, ThemeMapData> alphaCache;
|
||||||
|
Loading…
Reference in New Issue
Block a user