Hi,

I'm trying to fix BUG 212342. It seems like if variable is put to QVariant and 
then as a parameter to setData it does not work. If same variable is put as a 
parameter to setData directly it works? see attached patch. I think this 
happened after updating to Qt 4.6.

Petri
Index: soliddeviceengine.cpp
===================================================================
--- soliddeviceengine.cpp	(revision 1042590)
+++ soliddeviceengine.cpp	(working copy)
@@ -157,13 +157,13 @@
         setData(name, I18N_NOOP("File Path"), storageaccess->filePath());
 
         if (storageaccess->isAccessible()) {
-            QVariant freeDiskVar;
-            qlonglong freeDisk = freeDiskSpace(storageaccess->filePath());
-            if ( freeDisk != -1 ) {
-                freeDiskVar.setValue( freeDisk );
-            }
             if (!device.is<Solid::OpticalDisc>()) {
-                setData(name, I18N_NOOP("Free Space"), freeDiskVar );
+                qlonglong freeDisk = freeDiskSpace(storageaccess->filePath());
+                if (freeDisk != -1) {
+                    setData(name, I18N_NOOP("Free Space"), freeDisk);
+                } else {
+                    setData(name, I18N_NOOP("Free Space"), QVariant());
+                }
             }
         }
 
@@ -550,14 +550,16 @@
     }
 
     Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
-    if (storageaccess == 0) return false;
+    if (storageaccess == 0) {
+        return false;
+    }
 
-    QVariant freeSpaceVar;
     qlonglong freeSpace = freeDiskSpace(storageaccess->filePath());
-    if ( freeSpace != -1 ) {
-        freeSpaceVar.setValue( freeSpace );
+    if (freeSpace != -1) {
+        setData(udi, I18N_NOOP("Free Space"), freeSpace);
+    } else {
+        setData(udi, I18N_NOOP("Free Space"), QVariant());
     }
-    setData(udi, I18N_NOOP("Free Space"), freeSpaceVar );
     return true;
 }
 

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to