aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-13 12:33:06 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-13 14:32:34 +0100
commitcfe0b08b5439a27b4fdd14c29620e0492543f506 (patch)
treee45d282b23bec6504dbaba2b784bbaaa44f0b16b /src
parentb64f8dacae36fca948933cf56498d5e4ad3e2a07 (diff)
Remove QQmlCleanup
The only place where it was still used is QQmlOpenMetaObjecType. The only effect of QQmlCleanup is that clear() is eventually called by the engine. In the case of QQmlOpenMetaObjectType the only effect of that was that the "engine" member was reset. However, the only place where that member was used was in setCached(), and in that place it was irrelevant. There is no reason why setCached() should be prohibited when there is no engine. We may be worried that the property cache assigned to the open metaobject might go away somehow if there is no engine, but the cleanup mechanism clearly demonstrates that checking for the engine on setCached() does not protect against this. Fixes: QTBUG-90004 Change-Id: I05445eaeb53a64c70de366090ea2ee4aecf2bad8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/.prev_CMakeLists.txt1
-rw-r--r--src/qml/CMakeLists.txt1
-rw-r--r--src/qml/qml/qml.pri2
-rw-r--r--src/qml/qml/qqmlcleanup.cpp116
-rw-r--r--src/qml/qml/qqmlcleanup_p.h84
-rw-r--r--src/qml/qml/qqmlengine.cpp11
-rw-r--r--src/qml/qml/qqmlengine_p.h4
-rw-r--r--src/qml/qml/qqmlopenmetaobject.cpp18
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h6
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h1
-rw-r--r--src/qml/qml/qqmlscriptdata_p.h1
-rw-r--r--src/qml/qml/qqmltypenamecache_p.h1
-rw-r--r--src/quick/designer/qqmldesignermetaobject.cpp2
-rw-r--r--src/quick/items/qquickpathview.cpp3
14 files changed, 10 insertions, 241 deletions
diff --git a/src/qml/.prev_CMakeLists.txt b/src/qml/.prev_CMakeLists.txt
index ff158bf2ee..368dc66122 100644
--- a/src/qml/.prev_CMakeLists.txt
+++ b/src/qml/.prev_CMakeLists.txt
@@ -225,7 +225,6 @@ qt_internal_add_module(Qml
qml/qqmlapplicationengine.cpp qml/qqmlapplicationengine.h qml/qqmlapplicationengine_p.h
qml/qqmlbinding.cpp qml/qqmlbinding_p.h
qml/qqmlboundsignal.cpp qml/qqmlboundsignal_p.h
- qml/qqmlcleanup.cpp qml/qqmlcleanup_p.h
qml/qqmlcomponent.cpp qml/qqmlcomponent.h qml/qqmlcomponent_p.h
qml/qqmlcomponentattached_p.h
qml/qqmlcontext.cpp qml/qqmlcontext.h qml/qqmlcontext_p.h
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 385b9d923d..f59f1d8f23 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -226,7 +226,6 @@ qt_internal_add_module(Qml
qml/qqmlapplicationengine.cpp qml/qqmlapplicationengine.h qml/qqmlapplicationengine_p.h
qml/qqmlbinding.cpp qml/qqmlbinding_p.h
qml/qqmlboundsignal.cpp qml/qqmlboundsignal_p.h
- qml/qqmlcleanup.cpp qml/qqmlcleanup_p.h
qml/qqmlcomponent.cpp qml/qqmlcomponent.h qml/qqmlcomponent_p.h
qml/qqmlcomponentattached_p.h
qml/qqmlcontext.cpp qml/qqmlcontext.h qml/qqmlcontext_p.h
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index fa0783b237..ab5dedc061 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -34,7 +34,6 @@ SOURCES += \
$$PWD/qqmltypeloader.cpp \
$$PWD/qqmlinfo.cpp \
$$PWD/qqmlvaluetype.cpp \
- $$PWD/qqmlcleanup.cpp \
$$PWD/qqmlpropertycache.cpp \
$$PWD/qqmlmetaobject.cpp \
$$PWD/qqmlnotifier.cpp \
@@ -118,7 +117,6 @@ HEADERS += \
$$PWD/qqmllist_p.h \
$$PWD/qqmldata_p.h \
$$PWD/qqmlvaluetype_p.h \
- $$PWD/qqmlcleanup_p.h \
$$PWD/qqmlenumdata_p.h \
$$PWD/qqmlenumvalue_p.h \
$$PWD/qqmlpropertycache_p.h \
diff --git a/src/qml/qml/qqmlcleanup.cpp b/src/qml/qml/qqmlcleanup.cpp
deleted file mode 100644
index 0d57ef5fe8..0000000000
--- a/src/qml/qml/qqmlcleanup.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qqmlcleanup_p.h"
-
-#include "qqmlengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
-\internal
-\class QQmlCleanup
-\brief The QQmlCleanup provides a callback when a QQmlEngine is deleted.
-
-Any object that needs cleanup to occur before the QQmlEngine's V8 engine is
-destroyed should inherit from QQmlCleanup. The clear() virtual method will be
-called by QQmlEngine just before it destroys the context.
-*/
-
-
-/*
-Create a QQmlCleanup that is not associated with any engine.
-*/
-QQmlCleanup::QQmlCleanup()
-: prev(nullptr), next(nullptr), engine(nullptr)
-{
-}
-
-/*!
-Create a QQmlCleanup for \a engine
-*/
-QQmlCleanup::QQmlCleanup(QQmlEngine *engine)
-: prev(nullptr), next(nullptr), engine(nullptr)
-{
- if (!engine)
- return;
-
- addToEngine(engine);
-}
-
-/*!
-Adds this object to \a engine's cleanup list. hasEngine() must be false
-before calling this method.
-*/
-void QQmlCleanup::addToEngine(QQmlEngine *engine)
-{
- Q_ASSERT(engine);
- Q_ASSERT(QQmlEnginePrivate::isEngineThread(engine));
-
- this->engine = engine;
-
- QQmlEnginePrivate *p = QQmlEnginePrivate::get(engine);
-
- if (p->cleanup) next = p->cleanup;
- p->cleanup = this;
- prev = &p->cleanup;
- if (next) next->prev = &next;
-}
-
-/*!
-\fn bool QQmlCleanup::hasEngine() const
-
-Returns true if this QQmlCleanup is associated with an engine, otherwise false.
-*/
-
-/*!
-\internal
-*/
-QQmlCleanup::~QQmlCleanup()
-{
- Q_ASSERT(!prev || engine);
- Q_ASSERT(!prev || QQmlEnginePrivate::isEngineThread(engine));
-
- if (prev) *prev = next;
- if (next) next->prev = prev;
- prev = nullptr;
- next = nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcleanup_p.h b/src/qml/qml/qqmlcleanup_p.h
deleted file mode 100644
index 0e15c28b9d..0000000000
--- a/src/qml/qml/qqmlcleanup_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQMLCLEANUP_P_H
-#define QQMLCLEANUP_P_H
-
-#include <private/qtqmlglobal_p.h>
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QQmlEngine;
-
-class Q_QML_PRIVATE_EXPORT QQmlCleanup
-{
-public:
- QQmlCleanup();
- QQmlCleanup(QQmlEngine *);
- virtual ~QQmlCleanup();
-
- bool hasEngine() const { return prev != nullptr; }
- void addToEngine(QQmlEngine *);
-protected:
- virtual void clear() = 0;
-
-private:
- friend class QQmlEnginePrivate;
- QQmlCleanup **prev;
- QQmlCleanup *next;
-
- // Only used for asserts
- QQmlEngine *engine;
-};
-
-QT_END_NAMESPACE
-
-#endif // QQMLCLEANUP_P_H
-
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 5a20b93c2c..3c86bdbb1b 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -621,7 +621,7 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
profiler(nullptr),
#endif
outputWarningsToMsgLog(true),
- cleanup(nullptr), erroredBindings(nullptr), inProgressCreations(0),
+ erroredBindings(nullptr), inProgressCreations(0),
#if QT_CONFIG(qml_worker_script)
workerScriptEngine(nullptr),
#endif
@@ -639,15 +639,6 @@ QQmlEnginePrivate::~QQmlEnginePrivate()
if (inProgressCreations)
qWarning() << QQmlEngine::tr("There are still \"%1\" items in the process of being created at engine destruction.").arg(inProgressCreations);
- while (cleanup) {
- QQmlCleanup *c = cleanup;
- cleanup = c->next;
- if (cleanup) cleanup->prev = &cleanup;
- c->next = nullptr;
- c->prev = nullptr;
- c->clear();
- }
-
doDeleteInEngineThread();
if (incubationController) incubationController->d = nullptr;
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index b217f09ca6..9e9d24e90b 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -95,7 +95,6 @@ class QNetworkAccessManager;
class QQmlNetworkAccessManagerFactory;
class QQmlTypeNameCache;
class QQmlComponentAttached;
-class QQmlCleanup;
class QQmlDelayedError;
class QQmlObjectCreator;
class QDir;
@@ -169,9 +168,6 @@ public:
bool outputWarningsToMsgLog;
- // Registered cleanup handlers
- QQmlCleanup *cleanup;
-
// Bindings that have had errors during startup
QQmlDelayedError *erroredBindings;
int inProgressCreations;
diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp
index 5319700d85..b5264fcdfc 100644
--- a/src/qml/qml/qqmlopenmetaobject.cpp
+++ b/src/qml/qml/qqmlopenmetaobject.cpp
@@ -41,7 +41,6 @@
#include <private/qqmlpropertycache_p.h>
#include <private/qqmldata_p.h>
#include <private/qmetaobjectbuilder_p.h>
-#include <qqmlengine.h>
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -50,7 +49,7 @@ QT_BEGIN_NAMESPACE
class QQmlOpenMetaObjectTypePrivate
{
public:
- QQmlOpenMetaObjectTypePrivate() : mem(nullptr), cache(nullptr), engine(nullptr) {}
+ QQmlOpenMetaObjectTypePrivate() : mem(nullptr), cache(nullptr) {}
void init(const QMetaObject *metaObj);
@@ -60,14 +59,12 @@ public:
QMetaObjectBuilder mob;
QMetaObject *mem;
QQmlPropertyCache *cache;
- QQmlEngine *engine;
QSet<QQmlOpenMetaObject*> referers;
};
-QQmlOpenMetaObjectType::QQmlOpenMetaObjectType(const QMetaObject *base, QQmlEngine *engine)
- : QQmlCleanup(engine), d(new QQmlOpenMetaObjectTypePrivate)
+QQmlOpenMetaObjectType::QQmlOpenMetaObjectType(const QMetaObject *base)
+ : d(new QQmlOpenMetaObjectTypePrivate)
{
- d->engine = engine;
d->init(base);
}
@@ -80,11 +77,6 @@ QQmlOpenMetaObjectType::~QQmlOpenMetaObjectType()
delete d;
}
-void QQmlOpenMetaObjectType::clear()
-{
- d->engine = nullptr;
-}
-
int QQmlOpenMetaObjectType::propertyOffset() const
{
return d->propertyOffset;
@@ -258,7 +250,7 @@ public:
QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, const QMetaObject *base, bool automatic)
: d(new QQmlOpenMetaObjectPrivate(this, automatic, obj))
{
- d->type.adopt(new QQmlOpenMetaObjectType(base ? base : obj->metaObject(), nullptr));
+ d->type.adopt(new QQmlOpenMetaObjectType(base ? base : obj->metaObject()));
d->type->d->referers.insert(this);
QObjectPrivate *op = QObjectPrivate::get(obj);
@@ -428,7 +420,7 @@ bool QQmlOpenMetaObject::hasValue(int id) const
void QQmlOpenMetaObject::setCached(bool c)
{
- if (c == d->cacheProperties || !d->type->d->engine)
+ if (c == d->cacheProperties)
return;
d->cacheProperties = c;
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
index 441556a079..f6397c8c59 100644
--- a/src/qml/qml/qqmlopenmetaobject_p.h
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -55,7 +55,6 @@
#include <QtCore/QObject>
#include <private/qqmlrefcount_p.h>
-#include <private/qqmlcleanup_p.h>
#include <private/qtqmlglobal_p.h>
#include <private/qobject_p.h>
@@ -65,10 +64,10 @@ QT_BEGIN_NAMESPACE
class QQmlEngine;
class QMetaPropertyBuilder;
class QQmlOpenMetaObjectTypePrivate;
-class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObjectType : public QQmlRefCount, public QQmlCleanup
+class Q_QML_PRIVATE_EXPORT QQmlOpenMetaObjectType : public QQmlRefCount
{
public:
- QQmlOpenMetaObjectType(const QMetaObject *base, QQmlEngine *engine);
+ QQmlOpenMetaObjectType(const QMetaObject *base);
~QQmlOpenMetaObjectType() override;
void createProperties(const QVector<QByteArray> &names);
@@ -83,7 +82,6 @@ public:
protected:
virtual void propertyCreated(int, QMetaPropertyBuilder &);
- void clear() override;
private:
QQmlOpenMetaObjectTypePrivate *d;
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index e179123026..1adfc53cf5 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -53,7 +53,6 @@
#include <private/qqmlrefcount_p.h>
#include <private/qflagpointer_p.h>
-#include "qqmlcleanup_p.h"
#include "qqmlnotifier_p.h"
#include <private/qqmlpropertyindex_p.h>
diff --git a/src/qml/qml/qqmlscriptdata_p.h b/src/qml/qml/qqmlscriptdata_p.h
index 38b80e1bfa..816e968f6e 100644
--- a/src/qml/qml/qqmlscriptdata_p.h
+++ b/src/qml/qml/qqmlscriptdata_p.h
@@ -52,7 +52,6 @@
//
#include <private/qqmlrefcount_p.h>
-#include <private/qqmlcleanup_p.h>
#include <private/qqmlscriptblob_p.h>
#include <private/qv4value_p.h>
#include <private/qv4persistent_p.h>
diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h
index 41cb61a9ac..974f99ecae 100644
--- a/src/qml/qml/qqmltypenamecache_p.h
+++ b/src/qml/qml/qqmltypenamecache_p.h
@@ -52,7 +52,6 @@
//
#include <private/qqmlrefcount_p.h>
-#include "qqmlcleanup_p.h"
#include "qqmlmetatype_p.h"
#include <private/qstringhash_p.h>
diff --git a/src/quick/designer/qqmldesignermetaobject.cpp b/src/quick/designer/qqmldesignermetaobject.cpp
index 0aa5dc2613..0264b751f1 100644
--- a/src/quick/designer/qqmldesignermetaobject.cpp
+++ b/src/quick/designer/qqmldesignermetaobject.cpp
@@ -110,7 +110,7 @@ QQmlDesignerMetaObject* QQmlDesignerMetaObject::getNodeInstanceMetaObject(QObjec
void QQmlDesignerMetaObject::init(QObject *object, QQmlEngine *engine)
{
//Creating QQmlOpenMetaObjectType
- m_type = new QQmlOpenMetaObjectType(metaObjectParent(), engine);
+ m_type = new QQmlOpenMetaObjectType(metaObjectParent());
m_type->addref();
//Assigning type to this
copyTypeMetaObject();
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index d90ae7eb77..3d0b1b97f9 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -221,10 +221,9 @@ QQuickPathViewAttached *QQuickPathViewPrivate::attached(QQuickItem *item)
QQmlOpenMetaObjectType *QQuickPathViewPrivate::attachedType()
{
- Q_Q(QQuickPathView);
if (!attType) {
// pre-create one metatype to share with all attached objects
- attType = new QQmlOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject, qmlEngine(q));
+ attType = new QQmlOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject);
if (path) {
const auto attributes = path->attributes();
for (const QString &attr : attributes)