clang-tidy: Avoid another bogus warning about a potential leak
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 5 Sep 2018 19:09:19 +0000 (21:09 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Sep 2018 06:02:07 +0000 (08:02 +0200)
False positive, fixed by assigning to an attribute. Seems like
clang-tidy really doesn't like ephemeral objects even if they
have a parent.

src/qtui/statusnotifieritem.cpp
src/qtui/statusnotifieritem.h

index 48c747e..59a129e 100644 (file)
@@ -113,11 +113,11 @@ StatusNotifierItem::StatusNotifierItem(QWidget *parent)
     connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip()));
 
     // Service watcher to keep track of the StatusNotifierWatcher service
     connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip()));
 
     // Service watcher to keep track of the StatusNotifierWatcher service
-    QDBusServiceWatcher *watcher = new QDBusServiceWatcher(kSniWatcherService,
-                                                           QDBusConnection::sessionBus(),
-                                                           QDBusServiceWatcher::WatchForOwnerChange,
-                                                           this);
-    connect(watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString)));
+    _serviceWatcher = new QDBusServiceWatcher(kSniWatcherService,
+                                              QDBusConnection::sessionBus(),
+                                              QDBusServiceWatcher::WatchForOwnerChange,
+                                              this);
+    connect(_serviceWatcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString)));
 
     // Client instance for StatusNotifierWatcher
     _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService,
 
     // Client instance for StatusNotifierWatcher
     _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService,
index 8b8eb96..8e40be3 100644 (file)
@@ -44,6 +44,8 @@
 #  include "legacysystemtray.h"
 #endif
 
 #  include "legacysystemtray.h"
 #endif
 
+class QDBusServiceWatcher;
+
 class StatusNotifierItemDBus;
 
 class StatusNotifierItem : public StatusNotifierItemParent
 class StatusNotifierItemDBus;
 
 class StatusNotifierItem : public StatusNotifierItemParent
@@ -87,6 +89,7 @@ private slots:
 private:
     void registerToWatcher();
 
 private:
     void registerToWatcher();
 
+    QDBusServiceWatcher *_serviceWatcher{nullptr};
     StatusNotifierItemDBus *_statusNotifierItemDBus{nullptr};
     org::kde::StatusNotifierWatcher *_statusNotifierWatcher{nullptr};
     org::freedesktop::Notifications *_notificationsClient{nullptr};
     StatusNotifierItemDBus *_statusNotifierItemDBus{nullptr};
     org::kde::StatusNotifierWatcher *_statusNotifierWatcher{nullptr};
     org::freedesktop::Notifications *_notificationsClient{nullptr};