[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:28:46 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=208c11d

The following commit has been merged in the master branch:
commit 208c11de1a7222b9f91c5a5d7b9310e0a5c38d04
Author: Lamarque V. Souza <lamarque at kde.org>
Date:   Tue Jul 14 13:41:47 2015 -0300

    Fix battery widget not appearing after kdeconnectd restarts.
    
    I also added a workaround to prevent memory leak described in
    0f38eb34a4ee25f5a1c182822cebe5b44c788aaa.
    
    REVIEW: 124361
---
 interfaces/devicesmodel.cpp              | 20 +++++++++++++++++---
 interfaces/devicesmodel.h                |  2 +-
 plugins/battery/batterydbusinterface.cpp | 12 ++++++++++++
 plugins/battery/batterydbusinterface.h   |  1 +
 4 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp
index 3ac68ab..11b56da 100644
--- a/interfaces/devicesmodel.cpp
+++ b/interfaces/devicesmodel.cpp
@@ -50,7 +50,7 @@ DevicesModel::DevicesModel(QObject *parent)
     connect(m_dbusInterface, SIGNAL(deviceAdded(QString)),
             this, SLOT(deviceAdded(QString)));
     connect(m_dbusInterface, SIGNAL(deviceVisibilityChanged(QString,bool)),
-            this, SLOT(deviceUpdated(QString)));
+            this, SLOT(deviceUpdated(QString,bool)));
     connect(m_dbusInterface, SIGNAL(deviceRemoved(QString)),
             this, SLOT(deviceRemoved(QString)));
 
@@ -119,9 +119,20 @@ void DevicesModel::deviceRemoved(const QString& id)
     }
 }
 
-void DevicesModel::deviceUpdated(const QString& id)
+void DevicesModel::deviceUpdated(const QString& id, bool isVisible)
 {
     int row = rowForDevice(id);
+
+    if (row < 0 && isVisible) {
+        // FIXME: when m_dbusInterface is not valid refreshDeviceList() does
+        // nothing and we can miss some devices.
+        // Someone can reproduce this problem by restarting kdeconnectd while
+        // kdeconnect's plasmoid is still running.
+        qCDebug(KDECONNECT_INTERFACES) << "Adding missing device" << id;
+        deviceAdded(id);
+        row = rowForDevice(id);
+    }
+
     if (row >= 0) {
         const QModelIndex idx = index(row);
         Q_EMIT dataChanged(idx, idx);
@@ -190,7 +201,10 @@ void DevicesModel::nameChanged(const QString& newName)
 {
     Q_UNUSED(newName);
     DeviceDbusInterface* device = static_cast<DeviceDbusInterface*>(sender());
-    deviceUpdated(device->id());
+
+    Q_ASSERT(rowForDevice(device->id()) >= 0);
+
+    deviceUpdated(device->id(), true);
 }
 
 void DevicesModel::clearDevices()
diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h
index 816810e..e96af81 100644
--- a/interfaces/devicesmodel.h
+++ b/interfaces/devicesmodel.h
@@ -72,7 +72,7 @@ public:
 private Q_SLOTS:
     void deviceAdded(const QString& id);
     void deviceRemoved(const QString& id);
-    void deviceUpdated(const QString& id);
+    void deviceUpdated(const QString& id, bool isVisible);
     void refreshDeviceList();
     void receivedDeviceList(QDBusPendingCallWatcher* watcher);
     void nameChanged(const QString& newName);
diff --git a/plugins/battery/batterydbusinterface.cpp b/plugins/battery/batterydbusinterface.cpp
index 4b885ff..950de73 100644
--- a/plugins/battery/batterydbusinterface.cpp
+++ b/plugins/battery/batterydbusinterface.cpp
@@ -24,11 +24,23 @@
 #include <QDebug>
 #include <core/device.h>
 
+BatteryDbusInterface *BatteryDbusInterface::s_currentInterface = 0;
+
 BatteryDbusInterface::BatteryDbusInterface(const Device *device)
     : QDBusAbstractAdaptor(const_cast<Device*>(device))
 	, mCharge(-1)
 	, mIsCharging(false)
 {
+    // FIXME: Workaround to prevent memory leak.
+    // This makes the old BatteryDdbusInterface be deleted only after the new one is
+    // fully operational. That seems to prevent the crash mentioned in BatteryPlugin's
+    // destructor.
+    if (s_currentInterface) {
+        qCDebug(KDECONNECT_PLUGIN_BATTERY) << "Deleting stale BattteryDbusInterface object.";
+        s_currentInterface->deleteLater();
+    }
+
+    s_currentInterface = this;
 }
 
 BatteryDbusInterface::~BatteryDbusInterface()
diff --git a/plugins/battery/batterydbusinterface.h b/plugins/battery/batterydbusinterface.h
index fb5d768..434bed2 100644
--- a/plugins/battery/batterydbusinterface.h
+++ b/plugins/battery/batterydbusinterface.h
@@ -48,6 +48,7 @@ private:
     int mCharge;
     bool mIsCharging;
 
+    static BatteryDbusInterface *s_currentInterface;
 };
 
 #endif

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list