Make singletons owned by the C++ side
This commit is contained in:
@@ -93,8 +93,9 @@ public:
|
|||||||
Q_ENUM(PasswordStatus)
|
Q_ENUM(PasswordStatus)
|
||||||
|
|
||||||
static Controller &instance();
|
static Controller &instance();
|
||||||
static Controller *create(QQmlEngine *, QJSEngine *)
|
static Controller *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ public:
|
|||||||
static CustomEmojiModel _instance;
|
static CustomEmojiModel _instance;
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
static CustomEmojiModel *create(QQmlEngine *, QJSEngine *)
|
static CustomEmojiModel *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ public:
|
|||||||
static EmojiModel _instance;
|
static EmojiModel _instance;
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
static EmojiModel *create(QQmlEngine *, QJSEngine *)
|
static EmojiModel *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ class NotificationsManager : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static NotificationsManager &instance();
|
static NotificationsManager &instance();
|
||||||
static NotificationsManager *create(QQmlEngine *, QJSEngine *)
|
static NotificationsManager *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,9 @@ public:
|
|||||||
static Registration _instance;
|
static Registration _instance;
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
static Registration *create(QQmlEngine *, QJSEngine *)
|
static Registration *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,8 +90,9 @@ public:
|
|||||||
explicit RoomManager(QObject *parent = nullptr);
|
explicit RoomManager(QObject *parent = nullptr);
|
||||||
virtual ~RoomManager();
|
virtual ~RoomManager();
|
||||||
static RoomManager &instance();
|
static RoomManager &instance();
|
||||||
static RoomManager *create(QQmlEngine *, QJSEngine *)
|
static RoomManager *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
// SPDX-FileCopyrightText: 2022 Snehit Sah <hi@snehit.dev>
|
// SPDX-FileCopyrightText: 2022 Snehit Sah <hi@snehit.dev>
|
||||||
// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||||
|
|
||||||
@@ -33,8 +34,9 @@ public:
|
|||||||
static SpaceHierarchyCache _instance;
|
static SpaceHierarchyCache _instance;
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
static SpaceHierarchyCache *create(QQmlEngine *, QJSEngine *)
|
static SpaceHierarchyCache *create(QQmlEngine *engine, QJSEngine *)
|
||||||
{
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
return &instance();
|
return &instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user