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

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:26:48 UTC 2016


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

The following commit has been merged in the master branch:
commit a1d396ad202dbfd51ff7449c4c9659db78c21db2
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Sun Aug 18 18:22:54 2013 +0200

    Error checking in KCM, in case KDED is not running
    
    Added a dbus interface isValid check to prevent a crash.
    
    BUG: 323653
---
 kcm/devicesmodel.cpp | 14 +++++++++++---
 kcm/kcm.cpp          | 13 ++++++++++---
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/kcm/devicesmodel.cpp b/kcm/devicesmodel.cpp
index dc5b367..dc01bea 100644
--- a/kcm/devicesmodel.cpp
+++ b/kcm/devicesmodel.cpp
@@ -95,7 +95,6 @@ void DevicesModel::refreshDeviceList()
 
 QVariant DevicesModel::data(const QModelIndex &index, int role) const
 {
-
     if (!m_dbusInterface->isValid()) {
         switch (role) {
             case IconModelRole:
@@ -117,7 +116,7 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
 
     DeviceDbusInterface* device = m_deviceList[index.row()];
 
-    //FIXME: This function gets called lots of times per second, producing lots of dbus calls
+    //FIXME: This function gets called lots of times, producing lots of dbus calls. Add a cache.
     switch (role) {
         case IconModelRole: {
             bool paired = device->paired();
@@ -144,7 +143,16 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
 
 DeviceDbusInterface* DevicesModel::getDevice(const QModelIndex& index)
 {
-    return m_deviceList[index.row()];
+    if (!index.isValid()) {
+        return NULL;
+    }
+
+    int row = index.row();
+    if (row < 0 || row >= m_deviceList.size()) {
+        return NULL;
+    }
+
+    return m_deviceList[row];
 }
 
 int DevicesModel::rowCount(const QModelIndex &parent) const
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index 1bdd657..983cbdf 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -91,18 +91,25 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
     //Store previous device config
     pluginsConfigChanged();
 
+    if (!current.isValid()) {
+        kcmUi->deviceInfo->setVisible(false);
+        return;
+    }
+
     currentIndex = sortProxyModel->mapToSource(current);
+    currentDevice = devicesModel->getDevice(currentIndex);
 
-    bool valid = currentIndex.isValid();
+    bool valid = (currentDevice != NULL && currentDevice->isValid());
     kcmUi->deviceInfo->setVisible(valid);
-    if (!valid) return;
+    if (!valid) {
+        return;
+    }
 
     //FIXME: KPluginSelector has no way to remove a list of plugins and load another, so we need to destroy and recreate it each time
     delete kcmUi->pluginSelector;
     kcmUi->pluginSelector = new KPluginSelector(this);
     kcmUi->verticalLayout_2->addWidget(kcmUi->pluginSelector);
 
-    currentDevice = devicesModel->getDevice(currentIndex);
     kcmUi->deviceName->setText(currentDevice->name());
     kcmUi->trust_checkbox->setChecked(currentDevice->paired());
 

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list