Clone in a terminal:
Commit 53a8f4f
Johan Mattsson - 2013-09-07T19:29:29+00:00
53a8f4f4880d99a64920f2b93257b886bb89b280johan.mattsson.m@gmail.com

spawn native threads spawning threads in libbirdfont was a bad idea

Changed files (5)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex 038f310..29ee472 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -568,7 +568,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { 			MainWindow.get_current_glyph ().select_all_paths (); 		}); -		Gtk.MenuItem search_item = new Gtk.MenuItem.with_mnemonic (_("Search"));+		Gtk.MenuItem search_item = new Gtk.MenuItem.with_mnemonic (_("_Search")); 		edit_menu.append (search_item); 		search_item.activate.connect (() => { OverView.search (); });	 		search_item.add_accelerator ("activate", accel_group, 'F', Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE);diff --git a/libbirdfont/CharDatabase.vala b/libbirdfont/CharDatabase.valaindex 9e957ed..d945d51 100644--- a/libbirdfont/CharDatabase.vala+++ b/libbirdfont/CharDatabase.vala@@ -29,8 +29,6 @@ public class CharDatabase { 		index = new HashMultiMap<string, string> (); 	 		full_unicode_range = new GlyphRange ();-		-		CharDatabaseParser.run (); 	}  	public static GlyphRange search (string s) {diff --git a/libbirdfont/CharDatabaseParser.vala b/libbirdfont/CharDatabaseParser.valaindex 2a8dd72..33ab57d 100644--- a/libbirdfont/CharDatabaseParser.vala+++ b/libbirdfont/CharDatabaseParser.vala@@ -16,35 +16,13 @@ using Gee;  namespace BirdFont { -class CharDatabaseParser : GLib.Object {-	-	MainContext? context;+public class CharDatabaseParser : GLib.Object {++	signal void sync (); 	-	public CharDatabaseParser (MainContext? c) {	-		context = c;-		-		if (context == null) {-			warning ("No main context set.");-		}+	public CharDatabaseParser () {	 	} -	public static void run () {-		CharDatabaseParser thread_data;-		thread_data = new CharDatabaseParser (MainContext.default ());-		-		if (!Thread.supported ()) {-			warning ("Threads not supported, this might take a while.");-			thread_data.load ();-		} else {-			try {-				//new Thread<int> ("database parser", thread_data.load);-				Thread<int>.create<int> (thread_data.load, false);-			} catch (GLib.Error e) {-				warning (e.message);-			}-		}-	}-	 	private void add_entry (string data) { 		string[] e; 		string[] r;@@ -52,8 +30,7 @@ class CharDatabaseParser : GLib.Object { 		string index_values; 		unichar ch; 		string unicode_hex;-		Mutex mutex = new Mutex (); // wait for callback to finish-			+ 		if (data.has_prefix ("@")) { // ignore comments 			return; 		}@@ -79,26 +56,24 @@ class CharDatabaseParser : GLib.Object { 		 		ch = Font.to_unichar ("U+" + unicode_hex.down ()); 		-		mutex.lock (); 		Idle.add (() => { 			CharDatabase.full_unicode_range.add_single (ch); 			CharDatabase.entries.set (unicode_hex, data);-			mutex.unlock (); 			return false; 		});-+		sync ();+		 		foreach (string s in e) { 			r = s.split ("\n"); 			foreach (string t in r) {   				d = t.split (" "); 				foreach (string token in d) { 					if (token != "") {-						mutex.lock (); 						Idle.add (() => { 							CharDatabase.index.set (token, unicode_hex);-							mutex.unlock (); 							return false; 						});+						sync (); 					} 				} 			}diff --git a/libbirdfont/EmptyTab.vala b/libbirdfont/EmptyTab.valanew file mode 100644index 0000000..2fe31fd--- /dev/null+++ b/libbirdfont/EmptyTab.vala@@ -0,0 +1,38 @@+/*+    Copyright (C) 2013 Johan Mattsson++    This library is free software; you can redistribute it and/or modify +    it under the terms of the GNU Lesser General Public License as +    published by the Free Software Foundation; either version 3 of the +    License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful, but +    WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +    Lesser General Public License for more details.+*/++using Cairo;++namespace BirdFont {++public class EmptyTab : FontDisplay {+	+	string name;+	string label;+	+	public EmptyTab (string name, string label) {+		this.name = name;+		this.label = label;+	}+	+	public override string get_name () {+		return name;+	}++	public override string get_label () {+		return label;+	}+}++}\ No newline at end of filediff --git a/libbirdfont/TabBar.vala b/libbirdfont/TabBar.valaindex 116d655..afa0415 100644--- a/libbirdfont/TabBar.vala+++ b/libbirdfont/TabBar.vala@@ -586,6 +586,10 @@ public class TabBar : GLib.Object { 			i++; 		} 	}+	+	public void add_empty_tab (string name, string label) {+		add_tab (new EmptyTab (name, label));+	} }  }

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112