rhythmbox r6036 - in trunk: . rhythmdb tests



Author: jmatthew
Date: Tue Nov 11 10:41:08 2008
New Revision: 6036
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6036&view=rev

Log:
2008-11-11  Jonathan Matthew  <jonathan d14n org>

	* rhythmdb/rhythmdb-tree.c: (rhythmdb_tree_entry_set),
	(rhythmdb_tree_entry_delete):
	* rhythmdb/rhythmdb-tree.h:
	Add an entry flag that indicates the entry has been removed from the
	tree, and don't update the tree for changes made to entries that have
	been removed.  Fixes #539447.

	* tests/test-rhythmdb.c: (START_TEST), (rhythmdb_suite):
	Add a test for the above.


Modified:
   trunk/ChangeLog
   trunk/rhythmdb/rhythmdb-tree.c
   trunk/rhythmdb/rhythmdb-tree.h
   trunk/tests/test-rhythmdb.c

Modified: trunk/rhythmdb/rhythmdb-tree.c
==============================================================================
--- trunk/rhythmdb/rhythmdb-tree.c	(original)
+++ trunk/rhythmdb/rhythmdb-tree.c	Tue Nov 11 10:41:08 2008
@@ -1507,9 +1507,10 @@
 	type = entry->type;
 
 	/* don't process changes to entries we're loading, we'll get them
-	 * when the entry is complete.
+	 * when the entry is complete.  don't process changes for entries that
+	 * have been removed either.
 	 */
-	if (entry->flags & RHYTHMDB_ENTRY_TREE_LOADING)
+	if (entry->flags & (RHYTHMDB_ENTRY_TREE_LOADING | RHYTHMDB_ENTRY_TREE_REMOVED))
 		return FALSE;
 
 	/* Handle special properties */
@@ -1636,6 +1637,8 @@
 	g_mutex_lock (db->priv->entries_lock);
 	g_assert (g_hash_table_remove (db->priv->entries, entry->location));
 	g_assert (g_hash_table_remove (db->priv->entry_ids, GINT_TO_POINTER (entry->id)));
+
+	entry->flags |= RHYTHMDB_ENTRY_TREE_REMOVED;
 	rhythmdb_entry_unref (entry);
 	g_mutex_unlock (db->priv->entries_lock);
 }

Modified: trunk/rhythmdb/rhythmdb-tree.h
==============================================================================
--- trunk/rhythmdb/rhythmdb-tree.h	(original)
+++ trunk/rhythmdb/rhythmdb-tree.h	Tue Nov 11 10:41:08 2008
@@ -48,6 +48,7 @@
 /* RhythmDBEntry flags */
 enum {
 	RHYTHMDB_ENTRY_TREE_LOADING = RHYTHMDB_ENTRY_PRIVATE_FLAG_BASE,
+	RHYTHMDB_ENTRY_TREE_REMOVED = RHYTHMDB_ENTRY_PRIVATE_FLAG_BASE << 1,
 };
 
 typedef enum

Modified: trunk/tests/test-rhythmdb.c
==============================================================================
--- trunk/tests/test-rhythmdb.c	(original)
+++ trunk/tests/test-rhythmdb.c	Tue Nov 11 10:41:08 2008
@@ -427,6 +427,50 @@
 }
 END_TEST
 
+START_TEST (test_rhythmdb_modify_after_delete)
+{
+	RhythmDBEntry *entry;
+	GValue val = {0,};
+
+	entry = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///whee.ogg");
+	fail_unless (entry != NULL, "failed to create entry");
+
+	g_value_init (&val, G_TYPE_STRING);
+	g_value_set_static_string (&val, "Anything");
+	rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_GENRE, &val);
+	g_value_unset (&val);
+	
+	g_value_init (&val, G_TYPE_STRING);
+	g_value_set_static_string (&val, "Nothing");
+	rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_ARTIST, &val);
+	g_value_unset (&val);
+	
+	g_value_init (&val, G_TYPE_STRING);
+	g_value_set_static_string (&val, "Something");
+	rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_ALBUM, &val);
+	g_value_unset (&val);
+	
+	g_value_init (&val, G_TYPE_STRING);
+	g_value_set_static_string (&val, "Thing");
+	rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_TITLE, &val);
+	g_value_unset (&val);
+
+	rhythmdb_commit (db);
+	rhythmdb_entry_ref (entry);
+
+	rhythmdb_entry_delete (db, entry);
+	rhythmdb_commit (db);
+	
+	g_value_init (&val, G_TYPE_STRING);
+	g_value_set_static_string (&val, "Something Else");
+	rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_ALBUM, &val);
+	g_value_unset (&val);
+	
+	rhythmdb_commit (db);
+	rhythmdb_entry_unref (entry);
+}
+END_TEST
+
 static Suite *
 rhythmdb_suite (void)
 {
@@ -455,6 +499,7 @@
 
 	/* tests for breakable bug fixes */
 	tcase_add_test (tc_chain, test_rhythmdb_podcast_upgrade);
+	tcase_add_test (tc_chain, test_rhythmdb_modify_after_delete);
 
 	return s;
 }



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