[tomboy] (bug #655067) stop listening for spellchecking enable/disable after note delete



commit e9b0493af1173e0fa84916e4b30d3308ac45e55b
Author: Alemann Massho <armistice_con fastmail fm>
Date:   Sun Jun 24 15:13:50 2012 -0400

    (bug #655067) stop listening for spellchecking enable/disable after note delete
    
    A crash was ocurring whenever somebody would delete a note and then change the spellchecking box in the preferences. This happened because the NoteSpellChecker addin would attach or detach when the preferences changed regardless of whether the note had been deleted or not.
    
    Signed-off-by: Jared Jennings <jared jaredjennings org>

 Tomboy/Watchers.cs |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/Tomboy/Watchers.cs b/Tomboy/Watchers.cs
index 8a28a9c..d0d2f34 100644
--- a/Tomboy/Watchers.cs
+++ b/Tomboy/Watchers.cs
@@ -242,14 +242,14 @@ namespace Tomboy
 					gtkspell_detach (test_ptr);
 				return true;
 			} catch {
-			return false;
-		}
-	}
-
-	public static bool GtkSpellAvailable
-	{
-		get {
-			if (!gtkspell_available_tested) {
+			        return false;
+		        }
+	        }
+
+	        public static bool GtkSpellAvailable
+	        {
+		        get {
+			        if (!gtkspell_available_tested) {
 					gtkspell_available_result = DetectGtkSpellAvailable ();
 					gtkspell_available_tested = true;
 				}
@@ -266,12 +266,12 @@ namespace Tomboy
 
 		public override void Initialize ()
 		{
-			// Do nothing.
+			Manager.NoteDeleted += OnNoteDeleted;
 		}
 
 		public override void Shutdown ()
 		{
-			// Do nothing.
+			Manager.NoteDeleted -= OnNoteDeleted;
 		}
 
 		public override void OnNoteOpened ()
@@ -283,6 +283,13 @@ namespace Tomboy
 			}
 		}
 
+		// Stop listening for spellchecking enable/disable on delete (fixes bug #655067)
+		void OnNoteDeleted (object sender, Note deleted)
+		{
+			if (deleted == this.Note)
+				Preferences.SettingChanged -= OnEnableSpellcheckChanged;
+		}
+
 		void Attach ()
 		{
 			// Make sure we add this tag before attaching, so



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