[geany/geany-plugins] 48b607: spellcheck: Fix crash when closing a document quickly after adding data to it
Colomban Wendling
git-noreply at xxxxx
Sun Jan 26 22:25:58 UTC 2014
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sun, 26 Jan 2014 22:25:58 UTC
Commit: 48b607c181646064eb00abc54178c3fb2cac8c22
https://github.com/geany/geany-plugins/commit/48b607c181646064eb00abc54178c3fb2cac8c22
Log Message:
-----------
spellcheck: Fix crash when closing a document quickly after adding data to it
When using timeout callbacks, we need to check the documents are still valid
in the callbacks, in the case they e.g. have been closed since the timeout
started.
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