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 <andy.shaw@digia.com>
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Jens Bache-Wiig <jensbw@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
J-P Nurmi 2014-10-16 17:40:23 +02:00 committed by Shawn Rutledge
parent 2b666d9576
commit cd996c1b85

View File

@ -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);