[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdelibs/KDE/4.8.x] solid/solid/backends/fstab: Emit deviceRemoved/Added with the right deviceList s
From:       Dirk Mueller <mueller () kde ! org>
Date:       2012-06-06 20:56:46
Message-ID: 20120606205646.27237A60C8 () git ! kde ! org
[Download RAW message or body]

Git commit 63ccc4375ca1cd7f15fc04926b8019542120ba5a by Dirk Mueller, on behalf of Alex Fiestas.
Committed on 05/06/2012 at 18:12.
Pushed by mueller into branch 'KDE/4.8.x'.

Emit deviceRemoved/Added with the right deviceList set

The problem is quite straightforward, deviceAdded is being emitted when
the m_deviceList has the OLD list, so the new device is still NOT in it.
If the user of the library instances a device Solid::Device(UDI) in the
slot after that signal, the device will be null because it will not be
found in m_deviceList.

REVIEW: 105132

M  +8    -6    solid/solid/backends/fstab/fstabmanager.cpp

http://commits.kde.org/kdelibs/63ccc4375ca1cd7f15fc04926b8019542120ba5a

diff --git a/solid/solid/backends/fstab/fstabmanager.cpp b/solid/solid/backends/fstab/fstabmanager.cpp
index 608159f..6b29fa4 100644
--- a/solid/solid/backends/fstab/fstabmanager.cpp
+++ b/solid/solid/backends/fstab/fstabmanager.cpp
@@ -116,17 +116,19 @@ void FstabManager::_k_updateDeviceList()
     QSet<QString> newlist = deviceList.toSet();
     QSet<QString> oldlist = m_deviceList.toSet();
 
-    foreach(const QString &device, newlist) {
-        if ( !oldlist.contains(device) )
-            emit deviceAdded(udiPrefix() + "/" + device);
-    }
-
     foreach(const QString &device, oldlist) {
-        if ( !newlist.contains(device) )
+        if ( !newlist.contains(device) ) {
             emit deviceRemoved(udiPrefix() + "/" + device);
+        }
     }
 
     m_deviceList = deviceList;
+
+    foreach(const QString &device, newlist) {
+        if ( !oldlist.contains(device) ) {
+            emit deviceAdded(udiPrefix() + "/" + device);
+        }
+    }
 }
 
 void FstabManager::onMtabChanged()

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic