f-spot r4122 - in trunk: . src
- From: rubenv svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4122 - in trunk: . src
- Date: Mon, 30 Jun 2008 12:20:00 +0000 (UTC)
Author: rubenv
Date: Mon Jun 30 12:20:00 2008
New Revision: 4122
URL: http://svn.gnome.org/viewvc/f-spot?rev=4122&view=rev
Log:
2008-06-30 Ruben Vermeersch <ruben savanne be>
* src/PhotoQuery.cs: Batch all photos into one save operation.
* src/PhotoStore.cs: Avoid recursive transactions.
* src/QueuedSqliteDatabase.cs: Add boolean flag showing whether we are in
a transaction or not, clean up indentation a bit.
Modified:
trunk/ChangeLog
trunk/src/PhotoQuery.cs
trunk/src/PhotoStore.cs
trunk/src/QueuedSqliteDatabase.cs
Modified: trunk/src/PhotoQuery.cs
==============================================================================
--- trunk/src/PhotoQuery.cs (original)
+++ trunk/src/PhotoQuery.cs Mon Jun 30 12:20:00 2008
@@ -187,8 +187,10 @@
public void Commit (params int [] indexes)
{
+ List<Photo> to_commit = new List<Photo>();
foreach (int index in indexes)
- store.Commit (photos[index]);
+ to_commit.Add (photos [index]);
+ store.Commit (photos);
}
private void MarkChanged (object sender, DbItemEventArgs args)
Modified: trunk/src/PhotoStore.cs
==============================================================================
--- trunk/src/PhotoStore.cs (original)
+++ trunk/src/PhotoStore.cs Mon Jun 30 12:20:00 2008
@@ -401,9 +401,18 @@
Commit (args.Items, args);
}
+ public void Commit (Photo [] items)
+ {
+ DbItemEventArgs args = new DbItemEventArgs (items);
+ Commit (args.Items, args);
+ }
+
public void Commit (DbItem [] items, DbItemEventArgs args)
{
- if (items.Length > 1)
+ // Only use a transaction for multiple saves. Avoids recursive transactions.
+ bool use_transactions = !Database.InTransaction && items.Length > 1;
+
+ if (use_transactions)
Database.BeginTransaction ();
foreach (DbItem item in items)
@@ -411,7 +420,7 @@
EmitChanged (items, args);
- if (items.Length > 1)
+ if (use_transactions)
Database.CommitTransaction ();
}
Modified: trunk/src/QueuedSqliteDatabase.cs
==============================================================================
--- trunk/src/QueuedSqliteDatabase.cs (original)
+++ trunk/src/QueuedSqliteDatabase.cs Mon Jun 30 12:20:00 2008
@@ -90,31 +90,31 @@
queue_thread.Start();
}
- ~QueuedSqliteDatabase ()
- {
- Log.DebugFormat ("Finalizer called on {0}. Should be Disposed", GetType ());
- Dispose (false);
- }
+ ~QueuedSqliteDatabase ()
+ {
+ Log.DebugFormat ("Finalizer called on {0}. Should be Disposed", GetType ());
+ Dispose (false);
+ }
public void 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
- dispose_requested = true;
- queue_signal.Set();
- queue_thread.Join();
- }
- //Free unmanaged resources
+ 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;
+ already_disposed = true;
}
private void WaitForConnection()
@@ -157,6 +157,10 @@
{
return Query(new DbCommand(command.ToString()));
}
+
+ public bool InTransaction {
+ get { return current_transaction_thread == null; }
+ }
public void BeginTransaction()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]