[banshee] Gio: cast to GLib.IVolume before using the Adapter (bgo#721203)



commit 056fb85fb31f90c569c604b3b0968ea1e2df5f1a
Author: Roderich Schupp <roderich schupp googlemail com>
Date:   Thu Jan 2 12:07:35 2014 +0100

    Gio: cast to GLib.IVolume before using the Adapter (bgo#721203)
    
    Since gtk-sharp 2.99.1, the GLib.Drive.Volumes property returns
    a typed array of GLib.IVolume (as opposed to GLib.List in older
    gio-sharp). This means that it's not needed anymore to use the
    VolumeAdapter's API to cast each object of the iterator to this
    GInterface. Doing so would return null indeed.
    
    So we now use VolumeAdapter's API only if the element is not
    already a GLib.IVolume. With gtk-sharp 2.99.1 this will always
    be true (and we already depend on it), but leaving this code
    still compatible with gio-sharp will allow us to backport the
    fixes to bgo#721203 altogether, as there is some value in them
    (i.e. protection against NREs), and keeping the code in sync
    avoids merging problems.
    
    Signed-off-by: Andrés G. Aragoneses <knocte gmail com>

 .../LowLevel/RawBlockDevice.cs                     |    4 ++--
 1 files changed, 2 insertions(+), 2 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 73448c6..8f80379 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawBlockDevice.cs
@@ -43,8 +43,8 @@ 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.IVolume ?? GLib.VolumeAdapter.GetObject (maybe_volume 
as GLib.Object);
                     if (volume == null) {
                         yield return null;
                         continue;


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