summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qgtkstyle_p.cpp
diff options
context:
space:
mode:
authorDenis Mingulov <denis.mingulov@gmail.com>2010-09-28 15:17:05 (GMT)
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2010-09-28 15:17:05 (GMT)
commit72c91efce8ea1cb5daf9a6f48d19b414fe4e6d7a (patch)
treeb7c35e9a2ea8ee475b809015ca698f3877ac0764 /src/gui/styles/qgtkstyle_p.cpp
parenta33ef62469fd71bec7ed21e3a0ce7c2b12464a2d (diff)
downloadQt-72c91efce8ea1cb5daf9a6f48d19b414fe4e6d7a.zip
Qt-72c91efce8ea1cb5daf9a6f48d19b414fe4e6d7a.tar.gz
Qt-72c91efce8ea1cb5daf9a6f48d19b414fe4e6d7a.tar.bz2
GtkStyle: memory leaks in widget map are fixed
Task-number: QTBUG-13636 Merge-request: 817 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
Diffstat (limited to 'src/gui/styles/qgtkstyle_p.cpp')
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
index 4ed0fab..fdbe1f8 100644
--- a/src/gui/styles/qgtkstyle_p.cpp
+++ b/src/gui/styles/qgtkstyle_p.cpp
@@ -524,7 +524,9 @@ void QGtkStylePrivate::initGtkWidgets() const
QGtkStylePrivate::gtk_widget_realize(gtkWindow);
if (displayDepth == -1)
displayDepth = QGtkStylePrivate::gdk_drawable_get_depth(gtkWindow->window);
- gtkWidgetMap()->insert(QHashableLatin1Literal::fromData(strdup("GtkWindow")), gtkWindow);
+ QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow"));
+ removeWidgetFromMap(widgetPath);
+ gtkWidgetMap()->insert(widgetPath, gtkWindow);
// Make all other widgets. respect the text direction
@@ -576,6 +578,7 @@ void QGtkStylePrivate::initGtkWidgets() const
if (!strchr(it.key().data(), '.')) {
addAllSubWidgets(it.value());
}
+ free(const_cast<char *>(it.key().data()));
}
}
} else {
@@ -743,19 +746,24 @@ void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
}
}
+void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path)
+{
+ WidgetMap *map = gtkWidgetMap();
+ WidgetMap::iterator it = map->find(path);
+ if (it != map->end()) {
+ free(const_cast<char *>(it.key().data()));
+ map->erase(it);
+ }
+}
+
void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
{
if (Q_GTK_IS_WIDGET(widget)) {
gtk_widget_realize(widget);
QHashableLatin1Literal widgetPath = classPath(widget);
- WidgetMap *map = gtkWidgetMap();
- WidgetMap::iterator it = map->find(widgetPath);
- if (it != map->end()) {
- free(const_cast<char *>(it.key().data()));
- map->erase(it);
- }
- map->insert(widgetPath, widget);
+ removeWidgetFromMap(widgetPath);
+ gtkWidgetMap()->insert(widgetPath, widget);
#ifdef DUMP_GTK_WIDGET_TREE
qWarning("Inserted Gtk Widget: %s", widgetPath.data());
#endif