Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Beyer <s-beyer@gmx.net>2020-06-24 14:50:17 +0300
committerStephan Beyer <s-beyer@gmx.net>2020-06-24 14:50:17 +0300
commit08cb289b8c49687f4fb917ac81f630246b3bf551 (patch)
tree33feea48791d93e9ac7da017e46b03e2cf1c2d54 /src/gui/systray.cpp
parent6adb7987284176407a186778670e1a4b0f41aa57 (diff)
Fix SEGV (by circular ownership) at exit
Commit a12205f322d43476230881192616e47c9cf786ef (PR #1891) introduced a circular ownership: qmlRegisterSingletonType<Systray>(...) makes the QQmlEngine own the resulting singleton Systray instance, however, the QQmlEngine _trayEngine itself is owned by the Systray instance. This circular ownership results in a crash when the destructor of Systray calls the destructor of _trayEngine which attempts to call the destructor of Systray. This commit solves this problem by making ownCloudGui, which is the parent of Systray, the parent of the _trayEngine. Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Diffstat (limited to 'src/gui/systray.cpp')
-rw-r--r--src/gui/systray.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp
index a2b570970..0cb3c86a6 100644
--- a/src/gui/systray.cpp
+++ b/src/gui/systray.cpp
@@ -49,13 +49,17 @@ Systray *Systray::instance()
return _instance;
}
-Systray::Systray()
- : QSystemTrayIcon(nullptr)
- , _trayEngine(new QQmlApplicationEngine(this))
+void Systray::setTrayEngine(QQmlApplicationEngine *trayEngine)
{
+ _trayEngine = trayEngine;
+
_trayEngine->addImportPath("qrc:/qml/theme");
_trayEngine->addImageProvider("avatars", new ImageProvider);
+}
+Systray::Systray()
+ : QSystemTrayIcon(nullptr)
+{
qmlRegisterSingletonType<UserModel>("com.nextcloud.desktopclient", 1, 0, "UserModel",
[](QQmlEngine *, QJSEngine *) -> QObject * {
return UserModel::instance();
@@ -83,18 +87,22 @@ Systray::Systray()
void Systray::create()
{
- if (!AccountManager::instance()->accounts().isEmpty()) {
- _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
+ if (_trayEngine) {
+ if (!AccountManager::instance()->accounts().isEmpty()) {
+ _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
+ }
+ _trayEngine->load(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
}
- _trayEngine->load(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
hideWindow();
emit activated(QSystemTrayIcon::ActivationReason::Unknown);
}
void Systray::slotNewUserSelected()
{
- // Change ActivityModel
- _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
+ if (_trayEngine) {
+ // Change ActivityModel
+ _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
+ }
// Rebuild App list
UserAppsModel::instance()->buildAppList();