[gtk/matthiasc/for-master-2: 7/16] textview: Don't update action state in dispose



commit 47c21a255f9757596d9982a277e248b678f1e30a
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 4 22:40:11 2020 +0100

    textview: Don't update action state in dispose
    
    Only update the action state when we have a text buffer,
    there is no need to do it otherwise, since we are going
    to get a buffer before we get shown. This avoids triggering
    the action state updates from finalize, which is a bad
    time to be recreating the action muxer.

 gtk/gtktextview.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 4e6ce8d468..8277be0349 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1828,8 +1828,6 @@ gtk_text_view_set_buffer (GtkTextView   *text_view,
 {
   GtkTextViewPrivate *priv;
   GtkTextBuffer *old_buffer;
-  gboolean can_undo = FALSE;
-  gboolean can_redo = FALSE;
 
   g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
   g_return_if_fail (buffer == NULL || GTK_IS_TEXT_BUFFER (buffer));
@@ -1888,6 +1886,8 @@ gtk_text_view_set_buffer (GtkTextView   *text_view,
   if (buffer != NULL)
     {
       GtkTextIter start;
+      gboolean can_undo = FALSE;
+      gboolean can_redo = FALSE;
 
       g_object_ref (buffer);
 
@@ -1931,10 +1931,10 @@ gtk_text_view_set_buffer (GtkTextView   *text_view,
 
       if (priv->text_handle)
         gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_NONE);
-    }
 
-  gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.undo", can_undo);
-  gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.redo", can_redo);
+      gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.undo", can_undo);
+      gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.redo", can_redo);
+    }
 
   _gtk_text_view_accessible_set_buffer (text_view, old_buffer);
   if (old_buffer)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]