Fix leak in Systray
authorStephan Beyer <s-beyer@gmx.net>
Wed, 20 May 2020 22:28:23 +0000 (00:28 +0200)
committerStephan Beyer <s-beyer@gmx.net>
Wed, 20 May 2020 23:22:15 +0000 (01:22 +0200)
The member _trayEngine, allocated in the constructor, was leaking.

This commit sets the Systray instance as the Qt object tree parent of
the _trayEngine to fix the leak.

While at it, a few unused header includes have been removed.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
src/gui/systray.cpp
src/gui/systray.h

index 17ac06c6a1e95ed7a89a9b08553545142c81786b..bd508319b18b4431018052ed2057663e32a8c964 100644 (file)
 #include "tray/UserModel.h"
 
 #include <QCursor>
-#include <QDesktopServices>
 #include <QGuiApplication>
-#include <QQmlComponent>
 #include <QQmlApplicationEngine>
+#include <QQmlContext>
 #include <QScreen>
 
 #ifdef USE_FDO_NOTIFICATIONS
@@ -50,8 +49,8 @@ Systray *Systray::instance()
 Systray::Systray()
     : _isOpen(false)
     , _syncIsPaused(false)
+    , _trayEngine(new QQmlApplicationEngine(this))
 {
-    _trayEngine = new QQmlApplicationEngine;
     _trayEngine->addImportPath("qrc:/qml/theme");
     _trayEngine->addImageProvider("avatars", new ImageProvider);
     _trayEngine->rootContext()->setContextProperty("userModelBackend", UserModel::instance());
index 21f70ef4a8624dce80bea99b378e26de801bc942..8ec154d3dcff041f88bbcb1ed3829dafee801650 100644 (file)
 #define SYSTRAY_H
 
 #include <QSystemTrayIcon>
-#include <QQmlContext>
 
 #include "accountmanager.h"
 #include "tray/UserModel.h"
 
-class QIcon;
 class QQmlApplicationEngine;
 
 namespace OCC {