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

List:       kde-commits
Subject:    KDE/kdelibs/kfile
From:       Kevin Ottens <ervin () kde ! org>
Date:       2007-04-08 15:16:33
Message-ID: 1176045393.484751.26194.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 651595 by ervin:

More checking to avoid potential crashes. Could happen in case of bad 
timing, the device is already gone when the model is asked info about 
it.


 M  +15 -2     kfileplacesmodel.cpp  


--- trunk/KDE/kdelibs/kfile/kfileplacesmodel.cpp #651594:651595
@@ -255,12 +255,25 @@
 QVariant KFilePlacesModel::Private::deviceData(const QPersistentModelIndex &index, int role) const
 {
     if (index.isValid()) {
+        Solid::Device device = deviceModel->deviceForIndex(index);
+        Solid::Volume *volume = 0;
+
+        if (device.isValid()) volume = device.as<Solid::Volume>();
+
         switch (role)
         {
         case UrlRole:
-            return QUrl(KUrl(deviceModel->deviceForIndex(index).as<Solid::Volume>()->mountPoint()));
+            if (volume) {
+                return QUrl(KUrl(volume->mountPoint()));
+            } else {
+                return QVariant();
+            }
         case MountNeededRole:
-            return !deviceModel->deviceForIndex(index).as<Solid::Volume>()->isMounted();
+            if (volume) {
+                return !volume->isMounted();
+            } else {
+                return QVariant();
+            }
         default:
             return deviceModel->data(index, role);
         }
[prev in list] [next in list] [prev in thread] [next in thread] 

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