Clone in a terminal:
Commit dc27a60
Johan Mattsson - 2014-11-16T10:00:22+00:00
dc27a6058ade9ddda53705e6f3ad671cca546b66johan.mattsson.m@gmail.com

Don't redraw from the background thread

Changed files (5)

Diff

diff --git a/libbirdfont/MenuTab.vala b/libbirdfont/MenuTab.valaindex 8ef2438..7b57fc1 100644--- a/libbirdfont/MenuTab.vala+++ b/libbirdfont/MenuTab.vala@@ -20,9 +20,14 @@ public class MenuTab : FontDisplay { 	 *  	 * Do always check the return value of set_suppress_event when this 	 * variable is updated.+	 * +	 * This variable is used only in the gui thread. 	 */ 	public static bool suppress_event; +	/** True if the background thread is running. */+	public static bool background_thread;+ 	/** A notification sent when the file has been saved. */ 	public static SaveCallback save_callback; @@ -40,6 +45,7 @@ public class MenuTab : FontDisplay { 		export_callback = new ExportCallback (); 		 		suppress_event = false;+		background_thread = false; 	}  	public static void set_save_callback (SaveCallback c) {@@ -80,6 +86,7 @@ public class MenuTab : FontDisplay { 			warning ("suppress_event is already set"); 			return false; 		}+		background_thread = e; 		suppress_event = e; 		return true; 	}diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex f7eb6c4..a553dcd 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -61,8 +61,6 @@ public class OverView : FontDisplay { 			set_glyph_range (gr); 		} -		reset_zoom ();-		 		if (open_selected) { 			this.open_glyph_signal.connect ((glyph_collection) => { 				TabBar tabs = MainWindow.get_tab_bar ();@@ -109,6 +107,7 @@ public class OverView : FontDisplay { 		} 		 		update_scrollbar ();+		reset_zoom (); 	} 	 	public GlyphCollection add_empty_character_to_font (unichar character, bool unassigned, string name) {@@ -322,7 +321,6 @@ public class OverView : FontDisplay { 	 	OverViewItem get_selected_item () { 		if (visible_items.size == 0) {-			warning ("No items."); 			return new OverViewItem (null, '\0', 0, 0); 		} 		diff --git a/libbirdfont/TabBar.vala b/libbirdfont/TabBar.valaindex 5a10eec..25e41b8 100644--- a/libbirdfont/TabBar.vala+++ b/libbirdfont/TabBar.vala@@ -411,7 +411,7 @@ public class TabBar : GLib.Object { 		MainWindow.native_window.hide_text_input ();  		if (index == SHOW_MENU) {-			MainWindow.get_menu ().show_menu = ! MainWindow.get_menu ().show_menu;+			MainWindow.get_menu ().show_menu = !MainWindow.get_menu ().show_menu; 			GlyphCanvas.redraw (); 			return; 		}@@ -538,7 +538,10 @@ public class TabBar : GLib.Object { 	public void select_tab_click (double x, double y, int width, int height) { 		int over, close; 		-		MainWindow.get_menu ().show_menu = false;+		if (MainWindow.get_menu ().show_menu) {+			MainWindow.get_menu ().show_menu = false;+			GlyphCanvas.redraw ();+		} 		 		this.width = width; 		this.height = height;diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex b4bb9e0..c10af7a 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -274,6 +274,11 @@ public class Toolbox : GLib.Object  { 	}  	public static void redraw_tool_box () {+		if (MenuTab.suppress_event) {+			warn_if_test ("Don't redraw toolbox when background thread is running.");+			return;+		}+		 		Toolbox t = MainWindow.get_toolbox (); 		if (!is_null (t)) { 			t.redraw (0, 0, allocation_width, allocation_height);diff --git a/libbirdfont/ZoomBar.vala b/libbirdfont/ZoomBar.valaindex 0ad37af..02943ca 100644--- a/libbirdfont/ZoomBar.vala+++ b/libbirdfont/ZoomBar.vala@@ -50,7 +50,10 @@ public class ZoomBar : Tool { 	/** Zoom level from 0 to 1. */ 	public void set_zoom (double z) { 		zoom_level = z;-		Toolbox.redraw_tool_box ();+		+		if (!MenuTab.background_thread) {+			Toolbox.redraw_tool_box ();+		} 	} 	 	void set_zoom_from_mouse (double tx) {

Contact

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