Fix Runner and MatrixImageProvider singletons
This commit is contained in:
@@ -223,7 +223,7 @@ int main(int argc, char *argv[])
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.addImageProvider(QLatin1String("mxc"), new MatrixImageProvider);
|
engine.addImageProvider(QLatin1String("mxc"), MatrixImageProvider::create(&engine, &engine));
|
||||||
engine.addImageProvider(QLatin1String("blurhash"), new BlurhashImageProvider);
|
engine.addImageProvider(QLatin1String("blurhash"), new BlurhashImageProvider);
|
||||||
|
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/org/kde/neochat/qml/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:/org/kde/neochat/qml/main.qml")));
|
||||||
@@ -236,8 +236,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_RUNNER
|
#ifdef HAVE_RUNNER
|
||||||
Runner runner;
|
auto runner = Runner::create(&engine, &engine);
|
||||||
QDBusConnection::sessionBus().registerObject("/RoomRunner"_ls, &runner, QDBusConnection::ExportScriptableContents);
|
QDBusConnection::sessionBus().registerObject("/RoomRunner"_ls, runner, QDBusConnection::ExportScriptableContents);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QWindow *window = windowFromEngine(&engine);
|
QWindow *window = windowFromEngine(&engine);
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ class MatrixImageProvider : public QQuickAsyncImageProvider
|
|||||||
|
|
||||||
Q_PROPERTY(NeoChatConnection *connection MEMBER m_connection)
|
Q_PROPERTY(NeoChatConnection *connection MEMBER m_connection)
|
||||||
public:
|
public:
|
||||||
|
static MatrixImageProvider *create(QQmlEngine *engine, QJSEngine *)
|
||||||
|
{
|
||||||
|
static MatrixImageProvider instance;
|
||||||
|
engine->setObjectOwnership(&instance, QQmlEngine::CppOwnership);
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return a job to provide the image with the given ID.
|
* @brief Return a job to provide the image with the given ID.
|
||||||
*
|
*
|
||||||
@@ -69,4 +76,5 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
NeoChatConnection *m_connection = nullptr;
|
NeoChatConnection *m_connection = nullptr;
|
||||||
|
MatrixImageProvider() = default;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -170,7 +170,12 @@ class Runner : public QObject, protected QDBusContext
|
|||||||
|
|
||||||
Q_PROPERTY(RoomListModel *roomListModel READ roomListModel WRITE setRoomListModel NOTIFY roomListModelChanged)
|
Q_PROPERTY(RoomListModel *roomListModel READ roomListModel WRITE setRoomListModel NOTIFY roomListModelChanged)
|
||||||
public:
|
public:
|
||||||
Runner();
|
static Runner *create(QQmlEngine *engine, QJSEngine *)
|
||||||
|
{
|
||||||
|
static Runner instance;
|
||||||
|
engine->setObjectOwnership(&instance, QQmlEngine::CppOwnership);
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return a list of KRunner actions.
|
* @brief Return a list of KRunner actions.
|
||||||
@@ -200,4 +205,5 @@ private:
|
|||||||
|
|
||||||
SortFilterRoomListModel m_model;
|
SortFilterRoomListModel m_model;
|
||||||
RoomListModel m_sourceModel;
|
RoomListModel m_sourceModel;
|
||||||
|
Runner();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user