From 5d6f8b18fe77d2fc17a3c1d77d1c4baeff0e9704 Mon Sep 17 00:00:00 2001
From: Lars Knoll <lars.knoll@digia.com>
Date: Fri, 5 Jul 2013 13:29:57 +0200
Subject: [PATCH] Get rid of the first half of QQmlGuard usage

QQmlGuard was being used as a more performant replacement
for QPointer. QPointer got now fixed in Qt 5.0, making this
class obsolete.

Change-Id: I77eef066c4823af4b074ef32d4d78dbd67c36cd0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
---
 src/qml/qml/qqmlcomponent.cpp                 |  2 +-
 src/qml/qml/qqmlcontextwrapper_p.h            |  2 +-
 src/qml/qml/qqmlengine.cpp                    |  2 +-
 src/qml/qml/qqmlengine_p.h                    |  2 +-
 src/qml/qml/qqmlexpression_p.h                |  1 -
 src/qml/qml/qqmlincubator_p.h                 |  2 +-
 src/qml/qml/qqmllist_p.h                      |  3 +-
 src/qml/qml/qqmllistwrapper_p.h               |  5 ++--
 src/qml/qml/qqmlmetatype.cpp                  |  1 -
 src/qml/qml/qqmlnotifier_p.h                  |  1 -
 src/qml/qml/qqmlproperty_p.h                  |  5 ++--
 src/qml/qml/qqmltypewrapper_p.h               |  4 +--
 src/qml/qml/qqmlvaluetypewrapper.cpp          |  2 +-
 src/qml/qml/qqmlvme.cpp                       |  2 +-
 src/qml/qml/qqmlvme_p.h                       |  2 +-
 src/qml/qml/qqmlxmlhttprequest.cpp            |  2 +-
 src/qml/qml/v4/qv4include_p.h                 |  3 +-
 src/qml/qml/v4/qv4qobjectwrapper.cpp          |  5 ++--
 src/qml/qml/v4/qv4qobjectwrapper_p.h          |  6 ++--
 src/qml/qml/v4/qv4sequenceobject.cpp          |  2 +-
 src/qml/types/qqmlbind.cpp                    |  3 +-
 src/qml/types/qqmldelegatemodel_p_p.h         |  4 +--
 src/qml/types/qqmllistmodel.cpp               | 28 +++++++++----------
 src/qml/types/qqmllistmodel_p_p.h             |  2 +-
 src/qml/util/qqmladaptormodel.cpp             |  2 +-
 src/quick/items/qquickdrag.cpp                |  6 ++--
 src/quick/items/qquickdrag_p.h                |  1 +
 src/quick/items/qquickdroparea.cpp            |  4 +--
 src/quick/items/qquickflipable.cpp            |  7 ++---
 src/quick/items/qquickgridview_p.h            |  5 ++--
 src/quick/items/qquickitemview_p_p.h          |  2 +-
 src/quick/items/qquicklistview_p.h            |  5 ++--
 src/quick/items/qquickpathview_p_p.h          |  5 ++--
 src/quick/items/qquickrepeater_p_p.h          |  2 +-
 src/quick/items/qquickstateoperations.cpp     |  6 ++--
 src/quick/items/qquicktextinput_p_p.h         |  4 +--
 src/quick/items/qquickwindow.cpp              |  2 +-
 src/quick/items/qquickwindow_p.h              |  1 -
 .../qsgshareddistancefieldglyphcache_p.h      |  3 +-
 src/quick/util/qquickbehavior.cpp             |  3 +-
 src/quick/util/qquickpropertychanges.cpp      |  3 +-
 src/quick/util/qquickstatechangescript.cpp    |  1 -
 .../qml/qqmlecmascript/tst_qqmlecmascript.cpp | 13 ++++-----
 43 files changed, 76 insertions(+), 90 deletions(-)

diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 382b85685a..cd5d1e96b7 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1102,7 +1102,7 @@ public:
     static void markObjects(Managed *that);
 
     QV8Engine *v8;
-    QQmlGuard<QObject> parent;
+    QPointer<QObject> parent;
     QV4::Value valuemap;
     QV4::Value qmlGlobal;
     QV4::Value m_statusChanged;
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 646135b61f..0f44952567 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -93,7 +93,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
     bool isNullWrapper;
 
     QQmlGuardedContextData context;
-    QQmlGuard<QObject> scopeObject;
+    QPointer<QObject> scopeObject;
 };
 
 }
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index be1c28c62b..2b186dbb75 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -986,7 +986,7 @@ QQmlNetworkAccessManagerFactory *QQmlEngine::networkAccessManagerFactory() const
 void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
 {
     if (activeVME) {
-        activeVME->finalizeCallbacks.append(qMakePair(QQmlGuard<QObject>(obj), index));
+        activeVME->finalizeCallbacks.append(qMakePair(QPointer<QObject>(obj), index));
     } else {
         void *args[] = { 0 };
         QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, args);
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index b300dcc791..c57c70fa40 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -162,7 +162,7 @@ public:
 
     QUrl baseUrl;
 
-    typedef QPair<QQmlGuard<QObject>,int> FinalizeCallback;
+    typedef QPair<QPointer<QObject>,int> FinalizeCallback;
     void registerFinalizeCallback(QObject *obj, int index);
 
     QQmlVME *activeVME;
diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h
index b7f5624fb2..9cc5a326f8 100644
--- a/src/qml/qml/qqmlexpression_p.h
+++ b/src/qml/qml/qqmlexpression_p.h
@@ -55,7 +55,6 @@
 
 #include "qqmlexpression.h"
 
-#include <private/qqmlguard_p.h>
 #include <private/qqmlengine_p.h>
 #include <private/qfieldlist_p.h>
 #include <private/qflagpointer_p.h>
diff --git a/src/qml/qml/qqmlincubator_p.h b/src/qml/qml/qqmlincubator_p.h
index 54be20d68f..229919f37a 100644
--- a/src/qml/qml/qqmlincubator_p.h
+++ b/src/qml/qml/qqmlincubator_p.h
@@ -85,7 +85,7 @@ public:
     enum Progress { Execute, Completing, Completed };
     Progress progress;
 
-    QQmlGuard<QObject> result;
+    QPointer<QObject> result;
     QQmlGuardedContextData rootContext;
     QQmlCompiledData *compiledData;
     QQmlVME vme;
diff --git a/src/qml/qml/qqmllist_p.h b/src/qml/qml/qqmllist_p.h
index a39730049d..48732223dd 100644
--- a/src/qml/qml/qqmllist_p.h
+++ b/src/qml/qml/qqmllist_p.h
@@ -54,7 +54,6 @@
 //
 
 #include "qqmllist.h"
-#include "qqmlguard_p.h"
 #include "qqmlpropertycache_p.h"
 
 QT_BEGIN_NAMESPACE
@@ -66,7 +65,7 @@ public:
 
     static QQmlListReference init(const QQmlListProperty<QObject> &, int, QQmlEngine *);
 
-    QQmlGuard<QObject> object;
+    QPointer<QObject> object;
     QQmlMetaObject elementType;
     QQmlListProperty<QObject> property;
     int propertyType;
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index 83624d1423..c87b9b22d5 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -54,8 +54,9 @@
 //
 
 #include <QtCore/qglobal.h>
+#include <QtCore/qpointer.h>
+
 #include <QtQml/qqmllist.h>
-#include <private/qqmlguard_p.h>
 
 #include <private/qv4value_p.h>
 #include <private/qv4object_p.h>
@@ -88,7 +89,7 @@ public:
 
 private:
     QV8Engine *v8;
-    QQmlGuard<QObject> object;
+    QPointer<QObject> object;
     QQmlListProperty<QObject> property;
     int propertyType;
 
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 188fa7db0d..f3b4d6b1e5 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -44,7 +44,6 @@
 
 #include <private/qqmlproxymetaobject_p.h>
 #include <private/qqmlcustomparser_p.h>
-#include <private/qqmlguard_p.h>
 #include <private/qhashedstring_p.h>
 #include <private/qqmlimport_p.h>
 
diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h
index ea4a3e7822..93f2cd68da 100644
--- a/src/qml/qml/qqmlnotifier_p.h
+++ b/src/qml/qml/qqmlnotifier_p.h
@@ -43,7 +43,6 @@
 #define QQMLNOTIFIER_P_H
 
 #include "qqmldata_p.h"
-#include "qqmlguard_p.h"
 #include <QtCore/qmetaobject.h>
 #include <private/qmetaobject_p.h>
 
diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h
index 6482432a20..9af091ad46 100644
--- a/src/qml/qml/qqmlproperty_p.h
+++ b/src/qml/qml/qqmlproperty_p.h
@@ -59,7 +59,6 @@
 #include <private/qobject_p.h>
 #include <private/qtqmlglobal_p.h>
 #include <private/qqmlpropertycache_p.h>
-#include <private/qqmlguard_p.h>
 #include <private/qqmlboundsignalexpressionpointer_p.h>
 
 QT_BEGIN_NAMESPACE
@@ -78,8 +77,8 @@ public:
     Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
 
     QQmlContextData *context;
-    QQmlGuard<QQmlEngine> engine;
-    QQmlGuard<QObject> object;
+    QPointer<QQmlEngine> engine;
+    QPointer<QObject> object;
 
     QQmlPropertyData core;
 
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index 9ad364e94d..ae70367dc4 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -54,8 +54,8 @@
 //
 
 #include <QtCore/qglobal.h>
+#include <QtCore/qpointer.h>
 
-#include <private/qqmlguard_p.h>
 #include <private/qv4value_p.h>
 #include <private/qv4object_p.h>
 
@@ -89,7 +89,7 @@ public:
 private:
     QV8Engine *v8;
     TypeNameMode mode;
-    QQmlGuard<QObject> object;
+    QPointer<QObject> object;
 
     QQmlType *type;
     QQmlTypeNameCache *typeNamespace;
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 7355e0df02..05412e99a7 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -63,7 +63,7 @@ class QmlValueTypeReference : public QmlValueTypeWrapper
 public:
     QmlValueTypeReference(QV8Engine *engine);
 
-    QQmlGuard<QObject> object;
+    QPointer<QObject> object;
     int property;
 };
 
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index e4a996fac6..e32193e6f6 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -1367,7 +1367,7 @@ void QQmlVMEGuard::guard(QQmlVME *vme)
     clear();
     
     m_objectCount = vme->objects.count();
-    m_objects = new QQmlGuard<QObject>[m_objectCount];
+    m_objects = new QPointer<QObject>[m_objectCount];
     for (int ii = 0; ii < m_objectCount; ++ii)
         m_objects[ii] = vme->objects[ii];
 
diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h
index 750076f277..09e3237aee 100644
--- a/src/qml/qml/qqmlvme_p.h
+++ b/src/qml/qml/qqmlvme_p.h
@@ -202,7 +202,7 @@ public:
 
 private:
     int m_objectCount;
-    QQmlGuard<QObject> *m_objects;
+    QPointer<QObject> *m_objects;
     int m_contextCount;
     QQmlGuardedContextData *m_contexts;
 };
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 162f3dbd22..115814914d 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1047,7 +1047,7 @@ private:
     QString m_statusText;
     QNetworkRequest m_request;
     QStringList m_addedHeaders;
-    QQmlGuard<QNetworkReply> m_network;
+    QPointer<QNetworkReply> m_network;
     void destroyNetwork();
 
     QNetworkAccessManager *m_nam;
diff --git a/src/qml/qml/v4/qv4include_p.h b/src/qml/qml/v4/qv4include_p.h
index 76f5ec3e9a..d6bbcd1a60 100644
--- a/src/qml/qml/v4/qv4include_p.h
+++ b/src/qml/qml/v4/qv4include_p.h
@@ -57,7 +57,6 @@
 #include <QtCore/qurl.h>
 
 #include <private/qqmlcontext_p.h>
-#include <private/qqmlguard_p.h>
 
 #include <private/qv4value_p.h>
 #include <private/qv4context_p.h>
@@ -96,7 +95,7 @@ private:
 
     QV4::ExecutionEngine *v4;
     QNetworkAccessManager *m_network;
-    QQmlGuard<QNetworkReply> m_reply;
+    QPointer<QNetworkReply> m_reply;
 
     QUrl m_url;
     int m_redirectCount;
diff --git a/src/qml/qml/v4/qv4qobjectwrapper.cpp b/src/qml/qml/v4/qv4qobjectwrapper.cpp
index dc7b50edd3..f79675845b 100644
--- a/src/qml/qml/v4/qv4qobjectwrapper.cpp
+++ b/src/qml/qml/v4/qv4qobjectwrapper.cpp
@@ -41,7 +41,6 @@
 
 #include "qv4qobjectwrapper_p.h"
 
-#include <private/qqmlguard_p.h>
 #include <private/qqmlpropertycache_p.h>
 #include <private/qqmlengine_p.h>
 #include <private/qqmlvmemetaobject_p.h>
@@ -924,7 +923,7 @@ namespace {
 void QObjectWrapper::collectDeletables(Managed *m, GCDeletable **deletable)
 {
     QObjectWrapper *This = static_cast<QObjectWrapper*>(m);
-    QQmlGuard<QObject> &object = This->m_object;
+    QPointer<QObject> &object = This->m_object;
     if (!object)
         return;
 
@@ -1652,7 +1651,7 @@ QV4::Value QObjectMethod::method_toString(QV4::ExecutionContext *ctx)
 
         result += QString::fromUtf8(m_object->metaObject()->className());
         result += QLatin1String("(0x");
-        result += QString::number((quintptr)m_object.object(),16);
+        result += QString::number((quintptr)m_object.data(),16);
 
         if (!objectName.isEmpty()) {
             result += QLatin1String(", \"");
diff --git a/src/qml/qml/v4/qv4qobjectwrapper_p.h b/src/qml/qml/v4/qv4qobjectwrapper_p.h
index 73f19acb3f..6580d19fe9 100644
--- a/src/qml/qml/v4/qv4qobjectwrapper_p.h
+++ b/src/qml/qml/v4/qv4qobjectwrapper_p.h
@@ -101,7 +101,7 @@ private:
 
     QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const;
 
-    QQmlGuard<QObject> m_object;
+    QPointer<QObject> m_object;
     String *m_destroy;
     String *m_toString;
 
@@ -137,7 +137,7 @@ private:
     QV4::Value method_toString(QV4::ExecutionContext *ctx);
     QV4::Value method_destroy(QV4::ExecutionContext *ctx, Value *args, int argc);
 
-    QQmlGuard<QObject> m_object;
+    QPointer<QObject> m_object;
     int m_index;
     QV4::PersistentValue m_qmlGlobal;
 
@@ -161,7 +161,7 @@ struct QmlSignalHandler : public QV4::Object
     QObject *object() const { return m_object.data(); }
 
 private:
-    QQmlGuard<QObject> m_object;
+    QPointer<QObject> m_object;
     int m_signalIndex;
 
     static void destroy(Managed *that)
diff --git a/src/qml/qml/v4/qv4sequenceobject.cpp b/src/qml/qml/v4/qv4sequenceobject.cpp
index 454b327efb..be431e3c19 100644
--- a/src/qml/qml/v4/qv4sequenceobject.cpp
+++ b/src/qml/qml/v4/qv4sequenceobject.cpp
@@ -480,7 +480,7 @@ private:
     }
 
     mutable Container m_container;
-    QQmlGuard<QObject> m_object;
+    QPointer<QObject> m_object;
     int m_propertyIndex;
     bool m_isReference;
 
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp
index 4c4e541e11..129a81ee50 100644
--- a/src/qml/types/qqmlbind.cpp
+++ b/src/qml/types/qqmlbind.cpp
@@ -44,7 +44,6 @@
 #include <private/qqmlnullablevalue_p_p.h>
 #include <private/qqmlproperty_p.h>
 #include <private/qqmlbinding_p.h>
-#include <private/qqmlguard_p.h>
 
 #include <qqmlengine.h>
 #include <qqmlcontext.h>
@@ -66,7 +65,7 @@ public:
 
     QQmlNullableValue<bool> when;
     bool componentComplete;
-    QQmlGuard<QObject> obj;
+    QPointer<QObject> obj;
     QString propName;
     QQmlNullableValue<QVariant> value;
     QQmlProperty prop;
diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h
index 4e1adf175a..7931c4e18c 100644
--- a/src/qml/types/qqmldelegatemodel_p_p.h
+++ b/src/qml/types/qqmldelegatemodel_p_p.h
@@ -80,7 +80,7 @@ public:
     int parseGroups(const QStringList &groupNames) const;
     int parseGroups(const QV4::Value &groupNames) const;
 
-    QQmlGuard<QQmlDelegateModel> model;
+    QPointer<QQmlDelegateModel> model;
     const int groupCount;
     QV8Engine * const v8Engine;
     QQmlDelegateModelAttachedMetaObject *metaObject;
@@ -231,7 +231,7 @@ public:
             QQmlV4Function *args, Compositor::Group *group, int *index, int *count, int *groups) const;
 
     Compositor::Group group;
-    QQmlGuard<QQmlDelegateModel> model;
+    QPointer<QQmlDelegateModel> model;
     QQmlDelegateModelGroupEmitterList emitters;
     QQmlChangeSet changeSet;
     QString name;
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index f371429779..4c0b382439 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -121,7 +121,7 @@ const ListLayout::Role &ListLayout::getRoleOrCreate(const QV4::String *key, Role
 
 const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::Role::DataType type)
 {
-    const int dataSizes[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QQmlGuard<QObject>), sizeof(QVariantMap), sizeof(QDateTime) };
+    const int dataSizes[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QPointer<QObject>), sizeof(QVariantMap), sizeof(QDateTime) };
     const int dataAlignments[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap), sizeof(QDateTime) };
 
     Role *r = new Role;
@@ -636,7 +636,7 @@ QString *ListElement::getStringProperty(const ListLayout::Role &role)
 QObject *ListElement::getQObjectProperty(const ListLayout::Role &role)
 {
     char *mem = getPropertyMemory(role);
-    QQmlGuard<QObject> *o = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+    QPointer<QObject> *o = reinterpret_cast<QPointer<QObject> *>(mem);
     return o->data();
 }
 
@@ -662,22 +662,22 @@ QDateTime *ListElement::getDateTimeProperty(const ListLayout::Role &role)
     return dt;
 }
 
-QQmlGuard<QObject> *ListElement::getGuardProperty(const ListLayout::Role &role)
+QPointer<QObject> *ListElement::getGuardProperty(const ListLayout::Role &role)
 {
     char *mem = getPropertyMemory(role);
 
     bool existingGuard = false;
-    for (size_t i=0 ; i < sizeof(QQmlGuard<QObject>) ; ++i) {
+    for (size_t i=0 ; i < sizeof(QPointer<QObject>) ; ++i) {
         if (mem[i] != 0) {
             existingGuard = true;
             break;
         }
     }
 
-    QQmlGuard<QObject> *o = 0;
+    QPointer<QObject> *o = 0;
 
     if (existingGuard)
-        o = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+        o = reinterpret_cast<QPointer<QObject> *>(mem);
 
     return o;
 }
@@ -733,7 +733,7 @@ QVariant ListElement::getProperty(const ListLayout::Role &role, const QQmlListMo
             break;
         case ListLayout::Role::QObject:
             {
-                QQmlGuard<QObject> *guard = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+                QPointer<QObject> *guard = reinterpret_cast<QPointer<QObject> *>(mem);
                 QObject *object = guard->data();
                 if (object)
                     data = QVariant::fromValue(object);
@@ -840,9 +840,9 @@ int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o)
 
     if (role.type == ListLayout::Role::QObject) {
         char *mem = getPropertyMemory(role);
-        QQmlGuard<QObject> *g = reinterpret_cast<QQmlGuard<QObject> *>(mem);
+        QPointer<QObject> *g = reinterpret_cast<QPointer<QObject> *>(mem);
         bool existingGuard = false;
-        for (size_t i=0 ; i < sizeof(QQmlGuard<QObject>) ; ++i) {
+        for (size_t i=0 ; i < sizeof(QPointer<QObject>) ; ++i) {
             if (mem[i] != 0) {
                 existingGuard = true;
                 break;
@@ -851,11 +851,11 @@ int ListElement::setQObjectProperty(const ListLayout::Role &role, QObject *o)
         bool changed;
         if (existingGuard) {
             changed = g->data() != o;
-            g->~QQmlGuard();
+            g->~QPointer();
         } else {
             changed = true;
         }
-        new (mem) QQmlGuard<QObject>(o);
+        new (mem) QPointer<QObject>(o);
         if (changed)
             roleIndex = role.index;
     }
@@ -940,7 +940,7 @@ void ListElement::setBoolPropertyFast(const ListLayout::Role &role, bool b)
 void ListElement::setQObjectPropertyFast(const ListLayout::Role &role, QObject *o)
 {
     char *mem = getPropertyMemory(role);
-    new (mem) QQmlGuard<QObject>(o);
+    new (mem) QPointer<QObject>(o);
 }
 
 void ListElement::setListPropertyFast(const ListLayout::Role &role, ListModel *m)
@@ -1086,9 +1086,9 @@ void ListElement::destroy(ListLayout *layout)
                     break;
                 case ListLayout::Role::QObject:
                     {
-                        QQmlGuard<QObject> *guard = getGuardProperty(r);
+                        QPointer<QObject> *guard = getGuardProperty(r);
                         if (guard)
-                            guard->~QQmlGuard();
+                            guard->~QPointer();
                     }
                     break;
                 case ListLayout::Role::VariantMap:
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index de083a963b..c4d1e5ee55 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -278,7 +278,7 @@ private:
     ListModel *getListProperty(const ListLayout::Role &role);
     QString *getStringProperty(const ListLayout::Role &role);
     QObject *getQObjectProperty(const ListLayout::Role &role);
-    QQmlGuard<QObject> *getGuardProperty(const ListLayout::Role &role);
+    QPointer<QObject> *getGuardProperty(const ListLayout::Role &role);
     QVariantMap *getVariantMapProperty(const ListLayout::Role &role);
     QDateTime *getDateTimeProperty(const ListLayout::Role &role);
 
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 96a780f1df..4e81275e2f 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -686,7 +686,7 @@ public:
     QObject *modelData() const { return object; }
     QObject *proxiedObject() { return object; }
 
-    QQmlGuard<QObject> object;
+    QPointer<QObject> object;
 };
 
 class VDMObjectDelegateDataType : public QQmlRefCount, public QQmlAdaptorModel::Accessors
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index e828899204..f145ce259f 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -89,9 +89,9 @@ public:
 
     QQuickDragGrabber dragGrabber;
 
-    QQmlGuard<QObject> source;
-    QQmlGuard<QObject> target;
-    QQmlGuard<QQuickWindow> window;
+    QPointer<QObject> source;
+    QPointer<QObject> target;
+    QPointer<QQuickWindow> window;
     QQuickItem *attachedItem;
     QQuickDragMimeData *mimeData;
     Qt::DropAction proposedAction;
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index b7fa60b748..3680fd5754 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -45,6 +45,7 @@
 #include <QtQuick/qquickitem.h>
 
 #include <private/qv8engine_p.h>
+#include <private/qqmlguard_p.h>
 
 #include <QtCore/qmimedata.h>
 #include <QtCore/qstringlist.h>
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 659e606ef9..f453c42e5b 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -76,8 +76,8 @@ public:
     QRegExp keyRegExp;
     QPointF dragPosition;
     QQuickDropAreaDrag *drag;
-    QQmlGuard<QObject> source;
-    QQmlGuard<QMimeData> mimeData;
+    QPointer<QObject> source;
+    QPointer<QMimeData> mimeData;
 };
 
 QQuickDropAreaPrivate::QQuickDropAreaPrivate()
diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp
index 1ede6b0ea9..3428c66a62 100644
--- a/src/quick/items/qquickflipable.cpp
+++ b/src/quick/items/qquickflipable.cpp
@@ -42,7 +42,6 @@
 #include "qquickflipable_p.h"
 #include "qquickitem_p.h"
 
-#include <private/qqmlguard_p.h>
 
 #include <QtQml/qqmlinfo.h>
 
@@ -78,9 +77,9 @@ public:
     void setBackTransform();
 
     QQuickFlipable::Side current;
-    QQmlGuard<QQuickLocalTransform> backTransform;
-    QQmlGuard<QQuickItem> front;
-    QQmlGuard<QQuickItem> back;
+    QPointer<QQuickLocalTransform> backTransform;
+    QPointer<QQuickItem> front;
+    QPointer<QQuickItem> back;
 
     bool sideDirty;
     bool wantBackXFlipped;
diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h
index d98de1050f..09e11adf90 100644
--- a/src/quick/items/qquickgridview_p.h
+++ b/src/quick/items/qquickgridview_p.h
@@ -42,9 +42,10 @@
 #ifndef QQUICKGRIDVIEW_P_H
 #define QQUICKGRIDVIEW_P_H
 
+#include <QtCore/qpointer.h>
+
 #include "qquickitemview_p.h"
 
-#include <private/qqmlguard_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -133,7 +134,7 @@ Q_SIGNALS:
     void viewChanged();
 
 public:
-    QQmlGuard<QQuickGridView> m_view;
+    QPointer<QQuickGridView> m_view;
 };
 
 
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 1fa933ebd1..6b734eab92 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -249,7 +249,7 @@ public:
         q->polish();
     }
 
-    QQmlGuard<QQmlInstanceModel> model;
+    QPointer<QQmlInstanceModel> model;
     QVariant modelVariant;
     int itemCount;
     int buffer;
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index 3e766f8068..f612e7eab9 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -43,8 +43,7 @@
 #define QQUICKLISTVIEW_P_H
 
 #include "qquickitemview_p.h"
-
-#include <private/qqmlguard_p.h>
+#include <qpointer.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -192,7 +191,7 @@ Q_SIGNALS:
     void viewChanged();
 
 public:
-    QQmlGuard<QQuickListView> m_view;
+    QPointer<QQuickListView> m_view;
     QQuickItem *m_sectionItem;
 };
 
diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h
index 26533057d1..aa539e7cfc 100644
--- a/src/quick/items/qquickpathview_p_p.h
+++ b/src/quick/items/qquickpathview_p_p.h
@@ -61,7 +61,6 @@
 #include <QtCore/qcoreapplication.h>
 
 #include <private/qquickanimation_p_p.h>
-#include <private/qqmlguard_p.h>
 #include <private/qqmldelegatemodel_p.h>
 #include <private/qquicktimeline_p_p.h>
 
@@ -132,7 +131,7 @@ public:
 
     QQuickPath *path;
     int currentIndex;
-    QQmlGuard<QQuickItem> currentItem;
+    QPointer<QQuickItem> currentItem;
     qreal currentItemOffset;
     qreal startPc;
     QPointF startPoint;
@@ -169,7 +168,7 @@ public:
     qreal requestedZ;
     QList<QQuickItem *> items;
     QList<QQuickItem *> itemCache;
-    QQmlGuard<QQmlInstanceModel> model;
+    QPointer<QQmlInstanceModel> model;
     QVariant modelVariant;
     enum MovementReason { Other, SetIndex, Mouse };
     MovementReason moveReason;
diff --git a/src/quick/items/qquickrepeater_p_p.h b/src/quick/items/qquickrepeater_p_p.h
index a642f6479a..6430b3bc49 100644
--- a/src/quick/items/qquickrepeater_p_p.h
+++ b/src/quick/items/qquickrepeater_p_p.h
@@ -75,7 +75,7 @@ private:
 
     QPointer<QQmlInstanceModel> model;
     QVariant dataSource;
-    QQmlGuard<QObject> dataSourceAsObject;
+    QPointer<QObject> dataSourceAsObject;
     bool ownModel : 1;
     bool inRequest : 1;
     bool dataSourceIsObject : 1;
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index 24476b10a2..b1c548f95e 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -57,9 +57,9 @@ public:
         rewindParent(0), rewindStackBefore(0) {}
 
     QQuickItem *target;
-    QQmlGuard<QQuickItem> parent;
-    QQmlGuard<QQuickItem> origParent;
-    QQmlGuard<QQuickItem> origStackBefore;
+    QPointer<QQuickItem> parent;
+    QPointer<QQuickItem> origParent;
+    QPointer<QQuickItem> origStackBefore;
     QQuickItem *rewindParent;
     QQuickItem *rewindStackBefore;
 
diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h
index 11096cfa1d..7b3f61b1fb 100644
--- a/src/quick/items/qquicktextinput_p_p.h
+++ b/src/quick/items/qquicktextinput_p_p.h
@@ -189,9 +189,9 @@ public:
     QPointF pressPos;
     QPointF tripleClickStartPoint;
 
-    QQmlGuard<QQmlComponent> cursorComponent;
+    QPointer<QQmlComponent> cursorComponent;
 #ifndef QT_NO_VALIDATOR
-    QQmlGuard<QValidator> m_validator;
+    QPointer<QValidator> m_validator;
 #endif
 
     qreal hscroll;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 619c72afb8..cf2526e5a7 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -783,7 +783,7 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
 
 void QQuickWindowPrivate::notifyFocusChangesRecur(QQuickItem **items, int remaining)
 {
-    QQmlGuard<QQuickItem> item(*items);
+    QPointer<QQuickItem> item(*items);
 
     if (remaining)
         notifyFocusChangesRecur(items + 1, remaining - 1);
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 2dddd9ab68..aa7d7c5128 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -55,7 +55,6 @@
 
 #include "qquickitem.h"
 #include "qquickwindow.h"
-#include <private/qqmlguard_p.h>
 
 #include <QtQuick/private/qsgcontext_p.h>
 #include <private/qquickdrag_p.h>
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
index ac613c16f4..3ca5485be3 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
@@ -44,7 +44,6 @@
 
 #include <QtCore/qwaitcondition.h>
 #include <private/qsgadaptationlayer_p.h>
-#include <private/qqmlguard_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -116,7 +115,7 @@ private:
         Owner(const Owner &o) : item(o.item), ref(o.ref) {}
         Owner &operator =(const Owner &o) { item = o.item; ref = o.ref; return *this; }
 
-        QQmlGuard<QQuickItem> item;
+        QPointer<QQuickItem> item;
         int ref;
     };
 
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index 1e77084e42..2d765dc5ee 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -45,7 +45,6 @@
 #include <qqmlcontext.h>
 #include <qqmlinfo.h>
 #include <private/qqmlproperty_p.h>
-#include <private/qqmlguard_p.h>
 #include <private/qqmlengine_p.h>
 #include <private/qabstractanimationjob_p.h>
 #include <private/qquicktransition_p.h>
@@ -65,7 +64,7 @@ public:
 
     QQmlProperty property;
     QVariant targetValue;
-    QQmlGuard<QQuickAbstractAnimation> animation;
+    QPointer<QQuickAbstractAnimation> animation;
     QAbstractAnimationJob *animationInstance;
     bool enabled;
     bool finalized;
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index b2aa004e4f..e6f89b9b89 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -50,7 +50,6 @@
 #include <qqmlexpression.h>
 #include <private/qqmlbinding_p.h>
 #include <qqmlcontext.h>
-#include <private/qqmlguard_p.h>
 #include <private/qqmlproperty_p.h>
 #include <private/qqmlcontext_p.h>
 #include <private/qquickstate_p_p.h>
@@ -199,7 +198,7 @@ public:
     QQuickPropertyChangesPrivate() : decoded(true), restore(true),
                                 isExplicit(false) {}
 
-    QQmlGuard<QObject> object;
+    QPointer<QObject> object;
     QByteArray data;
 
     bool decoded : 1;
diff --git a/src/quick/util/qquickstatechangescript.cpp b/src/quick/util/qquickstatechangescript.cpp
index 3e89934478..2ad42f68fb 100644
--- a/src/quick/util/qquickstatechangescript.cpp
+++ b/src/quick/util/qquickstatechangescript.cpp
@@ -45,7 +45,6 @@
 #include <qqmlcontext.h>
 #include <qqmlexpression.h>
 #include <qqmlinfo.h>
-#include <private/qqmlguard_p.h>
 #include <private/qqmlcontext_p.h>
 #include <private/qqmlproperty_p.h>
 #include <private/qqmlbinding_p.h>
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 03d553c49c..3ac88dd086 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -45,7 +45,6 @@
 #include <QtQml/qqmlcontext.h>
 #include <QtCore/qfileinfo.h>
 #include <QtCore/qdebug.h>
-#include <QtQml/private/qqmlguard_p.h>
 #include <QtCore/qdir.h>
 #include <QtCore/qnumeric.h>
 #include <private/qqmlengine_p.h>
@@ -1575,9 +1574,9 @@ void tst_qqmlecmascript::dynamicDestruction()
 {
     {
     QQmlComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
-    QQmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
+    QPointer<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
     QVERIFY(object != 0);
-    QQmlGuard<QObject> createdQmlObject = 0;
+    QPointer<QObject> createdQmlObject = 0;
 
     QMetaObject::invokeMethod(object, "create");
     createdQmlObject = object->objectProperty();
@@ -1630,7 +1629,7 @@ void tst_qqmlecmascript::dynamicDestruction()
 
     {
     // QTBUG-23451
-    QQmlGuard<QObject> createdQmlObject = 0;
+    QPointer<QObject> createdQmlObject = 0;
     QQmlComponent component(&engine, testFileUrl("dynamicDeletion.3.qml"));
     QObject *o = component.create();
     QVERIFY(o != 0);
@@ -3274,7 +3273,7 @@ void tst_qqmlecmascript::ownershipRootObject()
     context->setContextObject(&own);
 
     QQmlComponent component(&engine, testFileUrl("ownershipRootObject.qml"));
-    QQmlGuard<QObject> object = component.create(context);
+    QPointer<QObject> object = component.create(context);
     QVERIFY(object);
 
     engine.collectGarbage();
@@ -3304,7 +3303,7 @@ void tst_qqmlecmascript::ownershipConsistency()
     QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
 
     QQmlComponent component(&engine, testFileUrl("ownershipConsistency.qml"));
-    QQmlGuard<QObject> object = component.create(context);
+    QPointer<QObject> object = component.create(context);
     QVERIFY(object);
 
     engine.collectGarbage();
@@ -5613,7 +5612,7 @@ void tst_qqmlecmascript::qtbug_9792()
     delete object;
 }
 
-// Verifies that QQmlGuard<>s used in the vmemetaobject are cleaned correctly
+// Verifies that QPointer<>s used in the vmemetaobject are cleaned correctly
 void tst_qqmlecmascript::qtcreatorbug_1289()
 {
     QQmlComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
-- 
GitLab