[f-spot] make the Close () call threadsafe



commit baecf2f4788439026d5e7b004e1a8db0da114968
Author: Stephane Delcroix <stephane delcroix org>
Date:   Mon Jun 29 10:07:07 2009 +0200

    make the Close () call threadsafe
    
    replace the preivous close_loader bool by a proper locking mechanism.

 src/ImageLoader.cs |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)
---
diff --git a/src/ImageLoader.cs b/src/ImageLoader.cs
index 709bfd5..f99add9 100644
--- a/src/ImageLoader.cs
+++ b/src/ImageLoader.cs
@@ -127,17 +127,11 @@ namespace FSpot {
 			base.Dispose ();
 		}
 
-		bool close_loader;
 		public new bool Close ()
 		{
-			bool ret = false;
 			lock (sync_handle) {
-				if (loading) {
-					close_loader = true;
-					ret = true;
-				}
+				return base.Close (true);
 			}
-			return ret || base.Close (true);
 		}
 #endregion
 
@@ -195,9 +189,7 @@ namespace FSpot {
 					notify_completed = true;
 				} else {
 					try {
-						if (close_loader)
-							base.Close (true);
-						else if (!is_disposed && Write (buffer, (ulong)byte_read))
+						if (!is_disposed && Write (buffer, (ulong)byte_read))
 							image_stream.BeginRead (buffer, 0, count, HandleReadDone, null);
 					} catch (System.ObjectDisposedException) {
 					} catch (GLib.GException) {



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