From cd996c1b85313e89e781f5bd02e5aeae98b69d73 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 16 Oct 2014 17:40:23 +0200 Subject: [PATCH] QGtkStyle: fix segfault after re-creating QApp QGtkStylePrivate::setupGtkWidget() cannot use a local static variable for the container, but it must insert it to the GTK widget map together with all other GTK widgets. The container is destructed as a GtkWindow child in the Qt post routine QGtkStylePrivate::destroyWidgetMap(). Task-number: QTBUG-41145 Change-Id: If1fda372ed1227edc779fa4951cbd6fbf6038499 Reviewed-by: Andy Shaw Reviewed-by: Dmitry Shachnev Reviewed-by: Jens Bache-Wiig Reviewed-by: Shawn Rutledge --- src/widgets/styles/qgtkstyle_p.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp index 06ee74bdfe..61d1cd796e 100644 --- a/src/widgets/styles/qgtkstyle_p.cpp +++ b/src/widgets/styles/qgtkstyle_p.cpp @@ -701,10 +701,12 @@ GtkWidget* QGtkStylePrivate::getTextColorWidget() const void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget) { if (Q_GTK_IS_WIDGET(widget)) { - static GtkWidget* protoLayout = 0; + GtkWidget *protoLayout = gtkWidgetMap()->value("GtkContainer"); if (!protoLayout) { protoLayout = QGtkStylePrivate::gtk_fixed_new(); QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout); + QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkContainer")); + gtkWidgetMap()->insert(widgetPath, protoLayout); } Q_ASSERT(protoLayout);