[gedit] ViewFrame: more robust code when using the start_mark
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] ViewFrame: more robust code when using the start_mark
- Date: Tue, 14 Jan 2014 20:59:22 +0000 (UTC)
commit 277bba71ee1b0684474afe9ffaaba3fbebc81607
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Jan 14 21:53:39 2014 +0100
ViewFrame: more robust code when using the start_mark
If the search box is hidden, the start_mark was deleted, but some
callbacks can be called later that uses the start_mark. So now the code
in the callbacks checks if the start_mark exists before using it.
gedit/gedit-view-frame.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index 8d52777..e7ee65c 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -104,6 +104,14 @@ gedit_view_frame_dispose (GObject *object)
{
GeditViewFrame *frame = GEDIT_VIEW_FRAME (object);
+ if (frame->priv->start_mark != NULL && frame->priv->view != NULL)
+ {
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->priv->view));
+
+ gtk_text_buffer_delete_mark (buffer, frame->priv->start_mark);
+ frame->priv->start_mark = NULL;
+ }
+
if (frame->priv->flush_timeout_id != 0)
{
g_source_remove (frame->priv->flush_timeout_id);
@@ -192,7 +200,7 @@ hide_search_widget (GeditViewFrame *frame,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->priv->view));
- if (cancel)
+ if (cancel && frame->priv->start_mark != NULL)
{
GtkTextIter iter;
@@ -203,9 +211,6 @@ hide_search_widget (GeditViewFrame *frame,
gedit_view_scroll_to_cursor (frame->priv->view);
}
- gtk_text_buffer_delete_mark (buffer, frame->priv->start_mark);
- frame->priv->start_mark = NULL;
-
gtk_widget_grab_focus (GTK_WIDGET (frame->priv->view));
}
@@ -323,7 +328,7 @@ start_search_finished (GtkSourceSearchContext *search_context,
&match_start,
&match_end);
}
- else
+ else if (frame->priv->start_mark != NULL)
{
GtkTextIter start_at;
@@ -1343,6 +1348,11 @@ start_interactive_search_real (GeditViewFrame *frame,
gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
}
+ if (frame->priv->start_mark != NULL)
+ {
+ gtk_text_buffer_delete_mark (buffer, frame->priv->start_mark);
+ }
+
frame->priv->start_mark = gtk_text_buffer_create_mark (buffer, NULL, &iter, FALSE);
gtk_revealer_set_reveal_child (frame->priv->revealer, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]