Problem with non-ascii tags and work-around



Hi,

Each time I tried to create tags, I encounter a problem the next time I
restart f-spot:
--SNIP--
Unable to find active server: Name 'org.gnome.FSpot' does not exist.

Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
in <0x000c8> TagStore:LoadAllTags ()
in <0x00050> TagStore:.ctor (Mono.Data.SqliteClient.SqliteConnection
connection, Boolean is_new)
in <0x000c2> Db:.ctor (System.String path, Boolean create_if_missing)
in <0x001f6> Driver:Main (System.String[] args)
--SNAP--

After some debugging with the source of the CVS version, I realized that
the problem happens when loading Tags from the db, and only if the tags
contains non-ascii characters... and I've a lot of friends with
non-ascii characters in their names.

Note that f-spot handled such names correctly while the session is open
and that the name are stored correctly in the db.

The faulty line generating an exception is this one (in TagStore.cs):

	string name = reader [1].ToString ();

I know that this is probably not the perfect solution, but the attached
patch below replaces unloadable names with a default string. This way, 
I can restart f-spot without cleaning the db (and then, recreating all
tags each time :( )

Stephane, now an happy f-spot user
--- f-spot/src/TagStore.cs	2005-11-16 15:48:52.000000000 +0100
+++ TagStore.cs	2005-11-16 15:53:41.000000000 +0100
@@ -307,7 +307,15 @@
 
 		while (reader.Read ()) {
 			uint id = Convert.ToUInt32 (reader [0]);
-			string name = reader [1].ToString ();
+
+			string name;
+			try { 
+				name = reader [1].ToString ();
+			}
+			catch(Exception) {
+				name = "Do not use non-ascii char in tags";
+			}
+
 			bool is_category = (Convert.ToUInt32 (reader [2]) != 0);
 
 			Tag tag;

Attachment: signature.asc
Description: This is a digitally signed message part



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