f-spot r4114 - in trunk: . src src/JobScheduler
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4114 - in trunk: . src src/JobScheduler
- Date: Fri, 27 Jun 2008 09:29:46 +0000 (UTC)
Author: sdelcroix
Date: Fri Jun 27 09:29:45 2008
New Revision: 4114
URL: http://svn.gnome.org/viewvc/f-spot?rev=4114&view=rev
Log:
2008-06-27 Stephane delcroix <sdelcroix novell com>
* Core.cs:
* Db.cs:
* JobScheduler/Scheduler.cs:
* PixbufLoader.cs:
* QueuedSqliteDatabase.cs: Finalize the running threads before calling
Gtk.Application.Exit (). Fixes bgo #528474.
Modified:
trunk/ChangeLog
trunk/src/Core.cs
trunk/src/Db.cs
trunk/src/JobScheduler/Scheduler.cs
trunk/src/PixbufLoader.cs
trunk/src/QueuedSqliteDatabase.cs
Modified: trunk/src/Core.cs
==============================================================================
--- trunk/src/Core.cs (original)
+++ trunk/src/Core.cs Fri Jun 27 09:29:45 2008
@@ -5,6 +5,7 @@
using org.freedesktop.DBus;
using FSpot.UI.Dialog;
+using FSpot.Utils;
namespace FSpot {
[Interface ("org.gnome.FSpot.Core")]
@@ -267,11 +268,13 @@
public void HandleDestroyed (object sender, System.EventArgs args)
{
+ Log.Information ("Exiting");
toplevels.Remove (sender);
if (toplevels.Count == 0) {
- // FIXME
- // Should use Application.Quit(), but for that to work we need to terminate the threads
- // first too.
+ Banshee.Kernel.Scheduler.Dispose ();
+ Core.Database.Dispose ();
+ PixbufLoader.Cleanup ();
+ Gtk.Application.Quit ();
System.Environment.Exit (0);
}
if (organizer != null && organizer.Window == sender)
Modified: trunk/src/Db.cs
==============================================================================
--- trunk/src/Db.cs (original)
+++ trunk/src/Db.cs Fri Jun 27 09:29:45 2008
@@ -262,7 +262,27 @@
public void Dispose ()
{
- Database.Dispose ();
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ bool already_disposed = false;
+ protected virtual void Dispose (bool is_disposing)
+ {
+ if (already_disposed)
+ return;
+ if (is_disposing) {//Free managed resources
+ Database.Dispose ();
+ }
+ //Free eunmanaged resources
+
+ already_disposed = true;
+ }
+
+ ~Db ()
+ {
+ Log.DebugFormat ("Finalizer called on {0}. Should be Disposed", GetType ());
+ Dispose (false);
}
public void BeginTransaction()
Modified: trunk/src/JobScheduler/Scheduler.cs
==============================================================================
--- trunk/src/JobScheduler/Scheduler.cs (original)
+++ trunk/src/JobScheduler/Scheduler.cs Fri Jun 27 09:29:45 2008
@@ -177,7 +177,7 @@
disposed = true;
}
}
-
+
private static bool IsDisposed()
{
if(disposed) {
Modified: trunk/src/PixbufLoader.cs
==============================================================================
--- trunk/src/PixbufLoader.cs (original)
+++ trunk/src/PixbufLoader.cs Fri Jun 27 09:29:45 2008
@@ -198,33 +198,37 @@
/* The worker thread's main function. */
private void WorkerThread ()
{
- while (true) {
- lock (processed_requests) {
- if (current_request != null) {
- processed_requests.Enqueue (current_request);
-
- if (! pending_notify_notified) {
- pending_notify.WakeupMain ();
- pending_notify_notified = true;
+ try {
+ while (true) {
+ lock (processed_requests) {
+ if (current_request != null) {
+ processed_requests.Enqueue (current_request);
+
+ if (! pending_notify_notified) {
+ pending_notify.WakeupMain ();
+ pending_notify_notified = true;
+ }
+
+ current_request = null;
}
+ }
+
+ lock (queue) {
- current_request = null;
+ while (queue.Count == 0 || block_count > 0)
+ Monitor.Wait (queue);
+
+ int pos = queue.Count - 1;
+
+ current_request = queue [pos] as RequestItem;
+ queue.RemoveAt (pos);
+ requests_by_path.Remove (current_request.path);
}
- }
-
- lock (queue) {
- while (queue.Count == 0 || block_count > 0)
- Monitor.Wait (queue);
-
- int pos = queue.Count - 1;
-
- current_request = queue [pos] as RequestItem;
- queue.RemoveAt (pos);
- requests_by_path.Remove (current_request.path);
+ ProcessRequest (current_request);
}
-
- ProcessRequest (current_request);
+ } catch (ThreadAbortException) {
+ //Aborting
}
}
Modified: trunk/src/QueuedSqliteDatabase.cs
==============================================================================
--- trunk/src/QueuedSqliteDatabase.cs (original)
+++ trunk/src/QueuedSqliteDatabase.cs Fri Jun 27 09:29:45 2008
@@ -32,6 +32,8 @@
using System.Collections.Generic;
using Mono.Data.SqliteClient;
+using FSpot.Utils;
+
namespace Banshee.Database
{
/// <summary>
@@ -87,13 +89,33 @@
queue_thread.IsBackground = true;
queue_thread.Start();
}
+
+ ~QueuedSqliteDatabase ()
+ {
+ Log.DebugFormat ("Finalizer called on {0}. Should be Disposed", GetType ());
+ Dispose (false);
+ }
public void Dispose()
{
- dispose_requested = true;
- queue_signal.Set();
- queue_thread.Join();
- }
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+
+ bool already_disposed = false;
+ protected virtual void Dispose (bool is_disposing)
+ {
+ if (already_disposed)
+ return;
+ if (is_disposing) { //Free managed resources
+ dispose_requested = true;
+ queue_signal.Set();
+ queue_thread.Join();
+ }
+ //Free unmanaged resources
+
+ already_disposed = true;
+ }
private void WaitForConnection()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]