diff --git a/src/designer/src/lib/shared/widgetfactory.cpp b/src/designer/src/lib/shared/widgetfactory.cpp
index 003096228f26e822d841c503f8f187a8f4b516ed..c467aeaaf83b5b916b94d31e7c1a55455ebccd0f 100644
--- a/src/designer/src/lib/shared/widgetfactory.cpp
+++ b/src/designer/src/lib/shared/widgetfactory.cpp
@@ -69,6 +69,7 @@
 #include <QtWidgets/qwizard.h>
 #include <QtCore/qdebug.h>
 #include <QtCore/qmetaobject.h>
+#include <QtCore/qpointer.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -188,8 +189,6 @@ WidgetFactory::Strings::Strings() :
 {
 }
 // ---------------- WidgetFactory
-QPointer<QWidget> *WidgetFactory::m_lastPassiveInteractor = new QPointer<QWidget>();
-bool WidgetFactory::m_lastWasAPassiveInteractor = false;
 const char *WidgetFactory::disableStyleCustomPaintingPropertyC = "_q_custom_style_disabled";
 
 WidgetFactory::WidgetFactory(QDesignerFormEditorInterface *core, QObject *parent)
@@ -789,59 +788,62 @@ static bool isTabBarInteractor(const QTabBar *tabBar)
     return false;
 }
 
-bool WidgetFactory::isPassiveInteractor(QWidget *widget)
+static bool isPassiveInteractorHelper(const QWidget *widget)
 {
     static const QString qtPassive = QStringLiteral("__qt__passive_");
     static const QString qtMainWindowSplitter = QStringLiteral("qt_qmainwindow_extended_splitter");
-    if (m_lastPassiveInteractor != 0 && (QWidget*)(*m_lastPassiveInteractor) == widget)
-        return m_lastWasAPassiveInteractor;
 
-    if (QApplication::activePopupWidget() || widget == 0) // if a popup is open, we have to make sure that this one is closed, else X might do funny things
+    if (qobject_cast<const QMenuBar*>(widget)
+#if QT_CONFIG(sizegrip)
+        || qobject_cast<const QSizeGrip*>(widget)
+#endif
+        || qobject_cast<const QMdiSubWindow*>(widget)
+        || qobject_cast<const QToolBar*>(widget)) {
         return true;
+    }
 
-    m_lastWasAPassiveInteractor = false;
-    (*m_lastPassiveInteractor) = widget;
-
-    if (const QTabBar *tabBar = qobject_cast<const QTabBar*>(widget)) {
+    if (qobject_cast<const QAbstractButton*>(widget)) {
+        auto parent = widget->parent();
+        if (qobject_cast<const QTabBar*>(parent) || qobject_cast<const QToolBox*>(parent))
+            return true;
+    } else if (const auto tabBar = qobject_cast<const QTabBar*>(widget)) {
         if (isTabBarInteractor(tabBar))
-            m_lastWasAPassiveInteractor = true;
-        return m_lastWasAPassiveInteractor;
-    }
-#ifndef QT_NO_SIZEGRIP
-    if (qobject_cast<QSizeGrip*>(widget))
-        return (m_lastWasAPassiveInteractor = true);
-#endif
-    if (qobject_cast<QMdiSubWindow*>(widget))
-        return (m_lastWasAPassiveInteractor = true);
-    if (qobject_cast<QAbstractButton*>(widget)
-        && (qobject_cast<QTabBar*>(widget->parent()) || qobject_cast<QToolBox*>(widget->parent()))) {
-        return (m_lastWasAPassiveInteractor = true);
-    }
-    if (qobject_cast<QMenuBar*>(widget))
-        return (m_lastWasAPassiveInteractor = true);
-    if (qobject_cast<QToolBar*>(widget))
-        return (m_lastWasAPassiveInteractor = true);
-    if (qobject_cast<QScrollBar*>(widget)) {
+            return true;
+    } else if (qobject_cast<const QScrollBar*>(widget)) {
         // A scroll bar is an interactor on a QAbstractScrollArea only.
-        if (const QWidget *parent = widget->parentWidget()) {
+        if (auto parent = widget->parentWidget()) {
             const QString objectName = parent->objectName();
             static const QString scrollAreaVContainer = QStringLiteral("qt_scrollarea_vcontainer");
             static const QString scrollAreaHContainer = QStringLiteral("qt_scrollarea_hcontainer");
-            if (objectName == scrollAreaVContainer || objectName == scrollAreaHContainer) {
-                m_lastWasAPassiveInteractor = true;
-                return m_lastWasAPassiveInteractor;
-            }
+            if (objectName == scrollAreaVContainer || objectName == scrollAreaHContainer)
+                return true;
         }
-    } else if (qstrcmp(widget->metaObject()->className(), "QDockWidgetTitle") == 0)
-        return (m_lastWasAPassiveInteractor = true);
-    else if (qstrcmp(widget->metaObject()->className(), "QWorkspaceTitleBar") == 0)
-        return (m_lastWasAPassiveInteractor = true);
-    const QString name = widget->objectName();
-    if (name.startsWith(qtPassive) || name == qtMainWindowSplitter) {
-        m_lastWasAPassiveInteractor = true;
-        return m_lastWasAPassiveInteractor;
+    } else if (qstrcmp(widget->metaObject()->className(), "QDockWidgetTitle") == 0) {
+        return true;
+    } else if (qstrcmp(widget->metaObject()->className(), "QWorkspaceTitleBar") == 0) {
+        return true;
     }
-    return m_lastWasAPassiveInteractor;
+    const QString &name = widget->objectName();
+    return name.startsWith(qtPassive) || name == qtMainWindowSplitter;
+}
+
+bool WidgetFactory::isPassiveInteractor(QWidget *widget)
+{
+    static bool lastWasAPassiveInteractor = false;
+    static QPointer<QWidget> lastPassiveInteractor;
+
+    if (!lastPassiveInteractor.isNull() && lastPassiveInteractor.data() == widget)
+        return lastWasAPassiveInteractor;
+
+    // if a popup is open, we have to make sure that this one is closed,
+    // else X might do funny things
+    if (QApplication::activePopupWidget() || widget == nullptr)
+        return true;
+
+    lastWasAPassiveInteractor = isPassiveInteractorHelper(widget);
+    lastPassiveInteractor = widget;
+
+    return lastWasAPassiveInteractor;
 }
 
 void WidgetFactory::formWindowAdded(QDesignerFormWindowInterface *formWindow)
diff --git a/src/designer/src/lib/shared/widgetfactory_p.h b/src/designer/src/lib/shared/widgetfactory_p.h
index 1d45e17cdb01f3df8a2459479b81a7cdc27edcf1..1d3c17bdf7cd49dd27b3b85ab588d44773959843 100644
--- a/src/designer/src/lib/shared/widgetfactory_p.h
+++ b/src/designer/src/lib/shared/widgetfactory_p.h
@@ -49,7 +49,6 @@
 #include <QtCore/qmap.h>
 #include <QtCore/qhash.h>
 #include <QtCore/qvariant.h>
-#include <QtCore/qpointer.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -163,9 +162,6 @@ private:
     QStyle *m_currentStyle;
     typedef QHash<QString, QStyle *> StyleCache;
     StyleCache m_styleCache;
-
-    static QPointer<QWidget> *m_lastPassiveInteractor;
-    static bool m_lastWasAPassiveInteractor;
 };
 
 } // namespace qdesigner_internal