[banshee] [Hyena.Data] Handle bad indices in MemoryListModel



commit 185d4a769dcf5446c9ba3138b49008a62ed42998
Author: Mike Gemünde <mike gemuende de>
Date:   Sat Apr 24 17:41:37 2010 +0200

    [Hyena.Data] Handle bad indices in MemoryListModel
    
    Makes sure that MemoryListModel returns correct values when bad indices are
    given. This makes it compatible with how Banshee's MemoryListModel works.
    
    Without this, grid view crashes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=616710

 src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs b/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs
index ae037ee..27ca87e 100644
--- a/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs
+++ b/src/Libraries/Hyena/Hyena.Data/MemoryListModel.cs
@@ -81,6 +81,10 @@ namespace Hyena.Data
         public override T this[int index] {
             get {
                 lock (list) {
+                    if (list.Count <= index || index < 0) {
+                        return default (T);
+                    }
+
                     return list[index];
                 }
             }



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