[banshee/stable-2.6] Gio: backport safer GLib.Volume handling code (bgo#721203)



commit ef4aeff702b0da452a03aa9f4e9fccf2825e2504
Author: Roderich Schupp <roderich schupp googlemail com>
Date:   Thu Jan 2 12:14:41 2014 +0100

    Gio: backport safer GLib.Volume handling code (bgo#721203)
    
    Backporting three commits [1][2][3] from master which make the
    code a bit safer against null values and make CD handling
    compatible with new GIO APIs (even though these APIs don't
    apply to the stable branch, the more in sync the code is,
    the better).
    
    [1] https://git.gnome.org/browse/banshee/commit/?id=20bacf9a3d06b2d136b474319f0b8224947bc4b8
    [2] https://git.gnome.org/browse/banshee/commit/?id=9d1ebf928edc793ba240603a3187f081b5d063d8
    [3] https://git.gnome.org/browse/banshee/commit/?id=056fb85fb31f90c569c604b3b0968ea1e2df5f1a
    
    Signed-off-by: Andrés G. Aragoneses <knocte gmail com>

 .../LowLevel/RawBlockDevice.cs                     |   12 +++++++++---
 .../LowLevel/UdevMetadataSource.cs                 |    3 +++
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs 
b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
index 59c0344..3290efa 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
@@ -43,15 +43,21 @@ namespace Banshee.Hardware.Gio
 
         public IEnumerable<Volume> Volumes {
             get {
-                foreach (var notVolume in Drive.Volumes) {
-                    var volume = GLib.VolumeAdapter.GetObject (notVolume as GLib.Object);
+                foreach (var maybe_volume in Drive.Volumes) {
+                    var volume = maybe_volume as GLib.Volume ?? GLib.VolumeAdapter.GetObject (maybe_volume 
as GLib.Object);
                     if (volume == null) {
                         yield return null;
+                        continue;
+                    }
+                    var device = Manager.GudevDeviceFromGioVolume (volume);
+                    if (device == null) {
+                        yield return null;
+                        continue;
                     }
                     yield return new Volume (new RawVolume (volume,
                                                             Manager,
                                                             new GioVolumeMetadataSource (volume),
-                                                            new UdevMetadataSource 
(Manager.GudevDeviceFromGioVolume (volume))));
+                                                            new UdevMetadataSource (device)));
                 }
             }
         }
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs 
b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs
index 04cb12b..7d10193 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/UdevMetadataSource.cs
@@ -71,6 +71,9 @@ namespace Banshee.Hardware.Gio
 
         public UdevMetadataSource (GUdev.Device device)
         {
+            if (device == null) {
+                throw new ArgumentNullException ("device");
+            }
             Device = device;
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]