[gedit/wip/loader-saver: 3/3] 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: 3/3] tab: fix a crash with scroll_to_cursor()
- Date: Mon, 23 Jun 2014 15:36:16 +0000 (UTC)
commit 1a1d5402e164e9fc191310771d0d955287faeb7f
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]