From 274404a2a349b80dbfc5dcd5a2daa0b0bf5d30d6 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 14 Apr 2010 12:06:24 +0200 Subject: Remove statically allocated pixmaps through the post routine In order to avoid native pixmap object leaking remove statically allocated pixmaps through the post routine. Reviewed-by: Friedemann Kleint Task-number: QTBUG-9815 --- .../components/propertyeditor/brushpropertymanager.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp b/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp index 6e9a698..2300b47 100644 --- a/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -119,21 +119,31 @@ Qt::BrushStyle BrushPropertyManager::brushStyleIndexToStyle(int brushStyleIndex) return Qt::NoBrush; } + +typedef QMap EnumIndexIconMap; + +static void clearBrushIcons(); +Q_GLOBAL_STATIC_WITH_INITIALIZER(EnumIndexIconMap, brushIcons, qAddPostRoutine(clearBrushIcons)) + +static void clearBrushIcons() +{ + brushIcons()->clear(); +} + const BrushPropertyManager::EnumIndexIconMap &BrushPropertyManager::brushStyleIcons() { // Create a map of icons for the brush style editor - static EnumIndexIconMap rc; - if (rc.empty()) { + if (brushIcons()->empty()) { const int brushStyleCount = sizeof(brushStyles)/sizeof(const char *); QBrush brush(Qt::black); const QIcon solidIcon = QtPropertyBrowserUtils::brushValueIcon(brush); for (int i = 0; i < brushStyleCount; i++) { const Qt::BrushStyle style = brushStyleIndexToStyle(i); brush.setStyle(style); - rc.insert(i, QtPropertyBrowserUtils::brushValueIcon(brush)); + brushIcons()->insert(i, QtPropertyBrowserUtils::brushValueIcon(brush)); } } - return rc; + return *(brushIcons()); } QString BrushPropertyManager::brushStyleIndexToString(int brushStyleIndex) -- cgit v0.12