[gspell] InlineCheckerTextBuffer: replace asserts by more useful warnings
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] InlineCheckerTextBuffer: replace asserts by more useful warnings
- Date: Sun, 2 Apr 2017 15:20:57 +0000 (UTC)
commit bc52e8383c47c2f295e91ef7f4d77cd9e4b98a6c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Apr 2 17:12:58 2017 +0200
InlineCheckerTextBuffer: replace asserts by more useful warnings
If the bug happens, it doesn't depend on gspell code, it depends on
lower-level libraries (GTK+, Pango). By printing warnings we avoid the
crash, and more useful info is printed.
https://bugzilla.gnome.org/show_bug.cgi?id=778883
gspell/gspell-inline-checker-text-buffer.c | 29 ++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index b7c2268..3c6b400 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -467,6 +467,7 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
GtkTextIter end;
GtkTextIter orig_start;
GtkTextIter orig_end;
+ gboolean bug = FALSE;
if (!_gspell_region_iter_get_subregion (&intersect_iter, &start, &end))
{
@@ -497,11 +498,31 @@ check_visible_region_in_view (GspellInlineCheckerTextBuffer *spell,
}
/* Ensure that we don't have an infinite loop. We must subtract
- * from scan_region at least [start, end], otherwise we will
- * re-check the same subregion again and again.
+ * from scan_region at least [orig_start, orig_end], otherwise
+ * we will re-check the same subregion again and again.
*/
- g_assert (gtk_text_iter_compare (&start, &orig_start) <= 0);
- g_assert (gtk_text_iter_compare (&orig_end, &end) <= 0);
+ if (gtk_text_iter_compare (&orig_start, &start) < 0)
+ {
+ g_warning ("Should not reach this code path.");
+ bug = TRUE;
+ start = orig_start;
+ }
+ if (gtk_text_iter_compare (&end, &orig_end) < 0)
+ {
+ g_warning ("Should not reach this code path.");
+ bug = TRUE;
+ end = orig_end;
+ }
+
+ if (bug)
+ {
+ gchar *text;
+
+ text = gtk_text_iter_get_slice (&start, &end);
+ g_warning ("Text that caused the bug: '%s'", text);
+ g_warning ("Please report the bug to: " PACKAGE_BUGREPORT);
+ g_free (text);
+ }
_gspell_region_subtract_subregion (spell->scan_region, &start, &end);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]