[gnumeric] GUI: Fix gtk+/X crash with large tooltips relating to fill-by-drag.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Fix gtk+/X crash with large tooltips relating to fill-by-drag.
- Date: Thu, 4 Nov 2010 20:42:37 +0000 (UTC)
commit f40daf97c2c369dce9572b93feaf896ceb47a30c
Author: Morten Welinder <terra gnome org>
Date: Thu Nov 4 16:42:06 2010 -0400
GUI: Fix gtk+/X crash with large tooltips relating to fill-by-drag.
ChangeLog | 7 +++++++
NEWS | 1 +
src/item-cursor.c | 34 +++++++++++++++++++++++++++++++---
src/sheet-autofill.c | 6 +++---
src/sheet-autofill.h | 8 ++++----
5 files changed, 46 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8a75f79..4401d5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-11-04 Morten Welinder <terra gnome org>
+ * src/item-cursor.c (cb_autofill_scroll): Limit size of tooltip to
+ 200x200 characters.
+
+ * src/sheet-autofill.c (gnm_autofill_hint)
+ (sheet_autofill_internal): Change to return GString* instead of
+ char*. All callers changed.
+
* src/cell.c (gnm_cell_convert_expr_to_value): Handle array
corners.
diff --git a/NEWS b/NEWS
index 8705a0e..60958c4 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Morten:
* Fix printing crash. [#632439]
* Partially fix problem with undefined names. [#633140]
* Fix analysis tools problems when "as values" is chosen.
+ * Fix gtk+/X crash with large tooltips.
--------------------------------------------------------------------------
Gnumeric 1.10.11
diff --git a/src/item-cursor.c b/src/item-cursor.c
index b0673ae..6d10a9a 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -911,6 +911,33 @@ item_cursor_drag_motion (ItemCursor *ic, double x, double y)
return TRUE;
}
+static void
+limit_string_height_and_width (GString *s, size_t wmax, size_t hmax)
+{
+ size_t l;
+ size_t p = 0;
+ for (l = 0; l < hmax; l++) {
+ size_t ll = 0;
+ size_t cut = 0;
+ while (s->str[p] != 0 && s->str[p] != '\n') {
+ if (ll == wmax)
+ cut = p;
+ ll++;
+ p += g_utf8_skip[(unsigned char)(s->str[p])];
+ }
+
+ if (cut) {
+ g_string_erase (s, cut, p - cut);
+ p = cut;
+ }
+ if (s->str[p] == 0)
+ return;
+ p++;
+ }
+ g_string_truncate (s, p);
+}
+
+
static gboolean
cb_autofill_scroll (GnmPane *pane, GnmPaneSlideInfo const *info)
{
@@ -968,7 +995,7 @@ cb_autofill_scroll (GnmPane *pane, GnmPaneSlideInfo const *info)
gboolean default_increment =
ic->drag_button_state & GDK_CONTROL_MASK;
Sheet *sheet = scg_sheet (ic->scg);
- char *hint;
+ GString *hint;
if (inverse_autofill)
hint = gnm_autofill_hint
@@ -984,8 +1011,9 @@ cb_autofill_scroll (GnmPane *pane, GnmPaneSlideInfo const *info)
ic->pos.end.col, ic->pos.end.row);
if (hint) {
- item_cursor_tip_setlabel (ic, hint);
- g_free (hint);
+ limit_string_height_and_width (hint, 200, 200);
+ item_cursor_tip_setlabel (ic, hint->str);
+ g_string_free (hint, TRUE);
} else
item_cursor_tip_setlabel (ic, "");
}
diff --git a/src/sheet-autofill.c b/src/sheet-autofill.c
index aa17a7f..af89b23 100644
--- a/src/sheet-autofill.c
+++ b/src/sheet-autofill.c
@@ -1200,7 +1200,7 @@ add_item (GString *dst, char *item, char const *sep)
g_string_append (dst, "?");
}
-static char *
+static GString *
sheet_autofill_internal (Sheet *sheet, gboolean singleton,
int base_col, int base_row,
int w, int h,
@@ -1291,7 +1291,7 @@ sheet_autofill_internal (Sheet *sheet, gboolean singleton,
}
}
- return doit ? NULL : g_string_free (res, FALSE);
+ return res;
}
@@ -1315,7 +1315,7 @@ gnm_autofill_fill (Sheet *sheet, gboolean singleton,
TRUE);
}
-char *
+GString *
gnm_autofill_hint (Sheet *sheet, gboolean default_increment,
int base_col, int base_row,
int w, int h,
diff --git a/src/sheet-autofill.h b/src/sheet-autofill.h
index 88f4d32..8ba2f91 100644
--- a/src/sheet-autofill.h
+++ b/src/sheet-autofill.h
@@ -14,10 +14,10 @@ void gnm_autofill_fill (Sheet *sheet, gboolean default_increment,
int w, int h,
int end_col, int end_row);
-char *gnm_autofill_hint (Sheet *sheet, gboolean default_increment,
- int base_col, int base_row,
- int w, int h,
- int end_col, int end_row);
+GString *gnm_autofill_hint (Sheet *sheet, gboolean default_increment,
+ int base_col, int base_row,
+ int w, int h,
+ int end_col, int end_row);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]