rpms/f-spot/F-13 0001-Don-t-segfault-on-shutdown-in-ImageLoaderThread.patch, NONE, 1.1 f-spot.spec, 1.100, 1.101

chkr chkr at fedoraproject.org
Wed Jun 23 23:25:59 UTC 2010


Author: chkr

Update of /cvs/pkgs/rpms/f-spot/F-13
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv11667

Modified Files:
	f-spot.spec 
Added Files:
	0001-Don-t-segfault-on-shutdown-in-ImageLoaderThread.patch 
Log Message:
* Wed Jun 23 2010 Christian Krause <chkr at fedoraproject.org> - 0.6.2-2
- Add upstream patch to prevent crash on exit


0001-Don-t-segfault-on-shutdown-in-ImageLoaderThread.patch:
 Core/App.cs          |    2 +-
 ImageLoaderThread.cs |   46 ++++++++++++++++++++++++++++++++--------------
 2 files changed, 33 insertions(+), 15 deletions(-)

--- NEW FILE 0001-Don-t-segfault-on-shutdown-in-ImageLoaderThread.patch ---
>From a0de2ac6269d43a73940be0a69dc137985f060d4 Mon Sep 17 00:00:00 2001
From: Ruben Vermeersch <ruben at savanne.be>
Date: Tue, 22 Jun 2010 22:48:34 +0200
Subject: [PATCH] Don't segfault on shutdown in ImageLoaderThread.

Backported fix for https://bugzilla.gnome.org/show_bug.cgi?id=621597
Requested here: https://bugzilla.gnome.org/show_bug.cgi?id=621823
---
 src/Core/App.cs          |    2 +-
 src/ImageLoaderThread.cs |   45 ++++++++++++++++++++++++++++++++-------------
 2 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/src/Core/App.cs b/src/Core/App.cs
index c2207df..d0a26a9 100644
--- a/src/Core/App.cs
+++ b/src/Core/App.cs
@@ -340,7 +340,7 @@ namespace FSpot
 				Log.Information ("Exiting...");
 				Banshee.Kernel.Scheduler.Dispose ();
 				Database.Dispose ();
-				ImageLoaderThread.Cleanup ();
+				ImageLoaderThread.CleanAll ();
 				Gtk.Application.Quit ();
 				System.Environment.Exit (0);
 			}
diff --git a/src/ImageLoaderThread.cs b/src/ImageLoaderThread.cs
index 148c7da..cc340cf 100644
--- a/src/ImageLoaderThread.cs
+++ b/src/ImageLoaderThread.cs
@@ -46,10 +46,10 @@ public class ImageLoaderThread {
 
 
 	// Private members.
+    static List<ImageLoaderThread> instances = new List<ImageLoaderThread> ();
 
 	/* The thread used to handle the requests.  */
 	private Thread worker_thread;
-	private static ArrayList all_worker_threads = new ArrayList ();
 
 	/* The request queue; it's shared between the threads so it
 	   needs to be locked prior to access.  */
@@ -76,6 +76,7 @@ public class ImageLoaderThread {
 	   already or not.  */
 	private bool pending_notify_notified;
 
+	volatile bool should_cancel = false;
 
 	// Public API.
 
@@ -91,10 +92,17 @@ public class ImageLoaderThread {
 		
 		pending_notify = new ThreadNotify (new Gtk.ReadyEvent (HandleProcessedRequests));
 
+        instances.Add (this);
+	}
+
+    void StartWorker ()
+    {
+        if (worker_thread != null)
+            return;
+
+		should_cancel = false;
 		worker_thread = new Thread (new ThreadStart (WorkerThread));
 		worker_thread.Start ();
-
-		all_worker_threads.Add (worker_thread);
 	}
 
 	int block_count;
@@ -112,17 +120,23 @@ public class ImageLoaderThread {
 		}
 	}
 
-	// FIXME?
-	static public void Cleanup ()
+	public void Cleanup ()
 	{
-		foreach (Thread t in all_worker_threads)
-			t.Abort ();
+		should_cancel = true;
+		if (worker_thread != null) {
+			lock (queue) { 
+				Monitor.Pulse (queue); 
+			}
+			worker_thread.Join ();
+		}
+		worker_thread = null;
 	}
 
-	public void Request (Uri uri, int order)
-	{
-		Request (uri, order, 0, 0);
-	}
+    public static void CleanAll ()
+    {
+        foreach (var thread in instances)
+            thread.Cleanup ();
+    }
 
 	public virtual void Request (Uri uri, int order, int width, int height)
 	{
@@ -172,6 +186,8 @@ public class ImageLoaderThread {
 
 	private bool InsertRequest (Uri uri, int order, int width, int height)
 	{
+        StartWorker ();
+
 		/* Check if this is the same as the request currently being processed.  */
 		lock(processed_requests) {
 			if (current_request != null && current_request.uri == uri)
@@ -205,7 +221,7 @@ public class ImageLoaderThread {
 	private void WorkerThread ()
 	{
 		try {
-			while (true) {
+			while (!should_cancel) {
 				lock (processed_requests) {
 					if (current_request != null) {
 						processed_requests.Enqueue (current_request);
@@ -221,8 +237,11 @@ public class ImageLoaderThread {
 	
 				lock (queue) {
 					
-					while (queue.Count == 0 || block_count > 0)
+					while ((queue.Count == 0 || block_count > 0) && !should_cancel)
 						Monitor.Wait (queue);
+
+					if (should_cancel)
+						return;
 					
 					int pos = queue.Count - 1;
 	
-- 
1.6.6.1



Index: f-spot.spec
===================================================================
RCS file: /cvs/pkgs/rpms/f-spot/F-13/f-spot.spec,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -p -r1.100 -r1.101
--- f-spot.spec	2 Jun 2010 21:24:45 -0000	1.100
+++ f-spot.spec	23 Jun 2010 23:25:58 -0000	1.101
@@ -1,6 +1,6 @@
 Name:           f-spot
 Version:        0.6.2
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Photo management application
 
 Group:          Applications/Multimedia
@@ -9,6 +9,9 @@ URL:            http://f-spot.org/
 Source0:        http://ftp.gnome.org/pub/gnome/sources/f-spot/0.6/f-spot-%{version}.tar.bz2
 # Fix schemas file: http://gitorious.org/f-spot/mainline/merge_requests/2161
 Patch1:         0001-remove-empty-default-tags-from-schemas-file.patch
+# Fix crash on exit
+# http://gitorious.org/f-spot/mainline/commit/a0de2ac6269d43a73940be0a69dc137985f060d4
+Patch2:         0001-Don-t-segfault-on-shutdown-in-ImageLoaderThread.patch
 # unmount cameras before importing
 Patch3:         0002-enhance-the-f-spot-import-script.patch
 # Use system gnome-keyring
@@ -73,6 +76,7 @@ photo collection in a slideshow as a scr
 %prep
 %setup -q
 %patch1 -p1 -b .schemas-fix
+%patch2 -p1 -b .crashonexit-fix
 %patch3 -p1 -b .gvfs-gphoto
 %patch4 -p1 -b .link-system-keyring
 
@@ -158,6 +162,9 @@ gtk-update-icon-cache %{_datadir}/icons/
 %{_datadir}/applications/screensavers/f-spot-screensaver.desktop
 
 %changelog
+* Wed Jun 23 2010 Christian Krause <chkr at fedoraproject.org> - 0.6.2-2
+- Add upstream patch to prevent crash on exit
+
 * Wed Jun 02 2010 Christian Krause <chkr at fedoraproject.org> - 0.6.2-1
 - Update to 0.6.2 (BZ 592895)
 - Remove patch to use system mono-addins (fixed upstream)



More information about the scm-commits mailing list