[geany/geany-plugins] c6e149: Merge pull request #129 from b4n/spellcheck/fix-timeout-callback

Enrico Tröger git-noreply at xxxxx
Sat Feb 1 13:14:37 UTC 2014


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sat, 01 Feb 2014 13:14:37 UTC
Commit:      c6e149e9491f6594e574d42633c45b81075503a6
             https://github.com/geany/geany-plugins/commit/c6e149e9491f6594e574d42633c45b81075503a6

Log Message:
-----------
Merge pull request #129 from b4n/spellcheck/fix-timeout-callback

spellcheck: Fix crash when closing a document quickly after adding data to it


Modified Paths:
--------------
    spellcheck/src/gui.c

Modified: spellcheck/src/gui.c
27 files changed, 16 insertions(+), 11 deletions(-)
===================================================================
@@ -412,21 +412,26 @@ static void indicator_clear_on_line(GeanyDocument *doc, gint line_number)
 static gboolean check_lines(gpointer data)
 {
 	GeanyDocument *doc = check_line_data.doc;
-	gchar *line;
-	gint line_number = check_line_data.line_number;
-	gint line_count = check_line_data.line_count;
-	gint i;
 
-	for (i = 0; i < line_count; i++)
+	/* since we're in an timeout callback, the document may have been closed */
+	if (DOC_VALID (doc))
 	{
-		line = sci_get_line(doc->editor->sci, line_number);
-		indicator_clear_on_line(doc, line_number);
-		if (sc_speller_process_line(doc, line_number, line) != 0)
+		gchar *line;
+		gint line_number = check_line_data.line_number;
+		gint line_count = check_line_data.line_count;
+		gint i;
+
+		for (i = 0; i < line_count; i++)
 		{
-			if (sc_info->use_msgwin)
-				msgwin_switch_tab(MSG_MESSAGE, FALSE);
+			line = sci_get_line(doc->editor->sci, line_number);
+			indicator_clear_on_line(doc, line_number);
+			if (sc_speller_process_line(doc, line_number, line) != 0)
+			{
+				if (sc_info->use_msgwin)
+					msgwin_switch_tab(MSG_MESSAGE, FALSE);
+			}
+			g_free(line);
 		}
-		g_free(line);
 	}
 	check_line_data.check_while_typing_idle_source_id = 0;
 	return FALSE;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list