[f-spot] Fixed several crashes due to Hashtable -> Dictionary work



commit 5cbe61cdb2eee9be81c0b01eadf738e376c29352
Author: Stephen Shaw <sshaw decriptor com>
Date:   Wed Nov 30 00:41:43 2011 -0700

    Fixed several crashes due to Hashtable -> Dictionary work
    
    Hashtables will return a null if it doesn't contain a
    valid key.  Dictionaries, however, throw a null key
    exception.

 src/Clients/MainApp/FSpot/PixbufCache.cs |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot/PixbufCache.cs b/src/Clients/MainApp/FSpot/PixbufCache.cs
index cb4e605..f276cbf 100644
--- a/src/Clients/MainApp/FSpot/PixbufCache.cs
+++ b/src/Clients/MainApp/FSpot/PixbufCache.cs
@@ -71,7 +71,9 @@ namespace FSpot
 		public void Request (SafeUri uri, object closure, int width, int height)
 		{
 			lock (items) {
-				CacheEntry entry = items[uri];
+				CacheEntry entry = null;
+				if (items.ContainsKey(uri))
+					entry = items[uri];
 
 				if (entry == null) {
 					entry = new CacheEntry (this, uri, closure, width, height);
@@ -117,11 +119,11 @@ namespace FSpot
 
 		public void Reload (SafeUri uri)
 		{
-			CacheEntry entry;
+			CacheEntry entry = null;
 
 			lock (items) {
-				entry = items [uri];
-				if (entry != null) {
+				if (items.ContainsKey(uri)){
+					entry = items [uri];
 					lock (entry) {
 						entry.Reload = true;
 					}
@@ -249,11 +251,12 @@ namespace FSpot
 
 		private CacheEntry ULookup (SafeUri uri)
 		{
-			CacheEntry entry = items [uri];
-			if (entry != null) {
+			CacheEntry entry = null;
+			if(items.ContainsKey(uri)) {
+				entry = items [uri];
 				MoveForward (entry);
 			}
-			return (CacheEntry) entry;
+			return entry;
 		}
 
 		public CacheEntry Lookup (SafeUri uri)
@@ -265,8 +268,9 @@ namespace FSpot
 
 		private void URemove (SafeUri uri)
 		{
-			CacheEntry entry = items [uri];
-			if (entry != null) {
+			CacheEntry entry = null;
+			if (items.ContainsKey (uri)) {
+				entry = items[uri];
 				items.Remove (uri);
 				items_mru.Remove (entry);
 				entry.Dispose ();



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