[gedit/wip/loader-saver: 18/19] tab: fix a crash with scroll_to_cursor()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/loader-saver: 18/19] tab: fix a crash with scroll_to_cursor()
- Date: Tue, 24 Jun 2014 22:25:23 +0000 (UTC)
commit b1a7ae716cf74d5009cba25db8eca714f35b2fe9
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Jun 23 17:34:47 2014 +0200
tab: fix a crash with scroll_to_cursor()
gedit/gedit-tab.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 9edd657..48da20d 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -63,6 +63,7 @@ struct _GeditTabPrivate
gint tmp_line_pos;
gint tmp_column_pos;
const GtkSourceEncoding *tmp_encoding; /* TODO remove */
+ guint idle_scroll;
GTimer *timer;
@@ -244,6 +245,12 @@ gedit_tab_finalize (GObject *object)
remove_auto_save_timeout (tab);
+ if (tab->priv->idle_scroll != 0)
+ {
+ g_source_remove (tab->priv->idle_scroll);
+ tab->priv->idle_scroll = 0;
+ }
+
G_OBJECT_CLASS (gedit_tab_parent_class)->finalize (object);
}
@@ -913,7 +920,8 @@ scroll_to_cursor (GeditTab *tab)
view = gedit_tab_get_view (tab);
gedit_view_scroll_to_cursor (view);
- return FALSE;
+ tab->priv->idle_scroll = 0;
+ return G_SOURCE_REMOVE;
}
static void
@@ -1029,7 +1037,10 @@ document_loaded (GeditDocument *document,
/* Scroll to the cursor when the document is loaded, we need
to do it in an idle as after the document is loaded the
textview is still redrawing and relocating its internals */
- g_idle_add ((GSourceFunc)scroll_to_cursor, tab);
+ if (tab->priv->idle_scroll == 0)
+ {
+ tab->priv->idle_scroll = g_idle_add ((GSourceFunc)scroll_to_cursor, tab);
+ }
/* if the document is readonly we don't care how many times the document
is opened */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]