From 7250a5c2f9dbb61e2c8289f1bf28db2300ce43ad Mon Sep 17 00:00:00 2001
From: Mitch Curtis <mitch.curtis@qt.io>
Date: Fri, 9 Nov 2018 15:49:57 +0100
Subject: [PATCH] Fix button menus not opening on the second attempt

Assign a parent to the QQmlComponent returned by
QQuickControlSettings1::styleComponent() so that it doesn't
get garbage collected by the QML engine. This was not
an issue until 5.12, but it seems like a good idea regardless.

Change-Id: I53265b23afab62e2276fe6e10d976a93a4f12e6f
Fixes: QTBUG-71238
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
---
 src/controls/Private/qquickcontrolsettings.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp
index 95c656b29..d06f931af 100644
--- a/src/controls/Private/qquickcontrolsettings.cpp
+++ b/src/controls/Private/qquickcontrolsettings.cpp
@@ -161,7 +161,7 @@ QQmlComponent *QQuickControlSettings1::styleComponent(const QUrl &styleDirUrl, c
         styleFileUrl = makeStyleComponentUrl(controlStyleName, m_styleMap.value(QStringLiteral("Base")).m_styleDirPath);
     }
 
-    return new QQmlComponent(qmlEngine(control), styleFileUrl);
+    return new QQmlComponent(qmlEngine(control), styleFileUrl, this);
 }
 
 static QString relativeStyleImportPath(QQmlEngine *engine, const QString &styleName)
-- 
GitLab