[hotssh] tab: Only free objects, don't do gtk+ inside dispose handler



commit 0418fb55488032514b1d0dfc37f6fd02d289e90b
Author: Colin Walters <walters verbum org>
Date:   Thu Dec 5 16:17:51 2013 -0500

    tab: Only free objects, don't do gtk+ inside dispose handler
    
    Otherwise we can emit signal handlers which then call back into us,
    and it's all just broken.  All we need to do in dispose() is free
    stuff.

 src/hotssh-tab.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/hotssh-tab.c b/src/hotssh-tab.c
index 40c8d80..846b87e 100644
--- a/src/hotssh-tab.c
+++ b/src/hotssh-tab.c
@@ -91,6 +91,7 @@ struct _HotSshTabPrivate
   HotSshTabPage active_page;
   guint authmechanism_index;
 
+  gboolean indisposed;
   char *hostname;
   GtkEntryCompletion *host_completion;
   GSocketConnectable *address;
@@ -156,18 +157,21 @@ state_reset_for_new_connection (HotSshTab                *self)
   HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self);
   g_debug ("reset state");
   g_clear_pointer (&priv->hostname, g_free);
-  g_object_notify ((GObject*)self, "hostname");
   g_clear_object (&priv->address);
   g_clear_object (&priv->connection);
   g_clear_object (&priv->cancellable);
-  vte_terminal_reset ((VteTerminal*)priv->terminal, TRUE, TRUE);
-  gtk_entry_set_text ((GtkEntry*)priv->password_entry, "");
-  reset_focus_state (self);
-  gtk_label_set_text ((GtkLabel*)priv->connection_text, "");
-  gtk_widget_show (priv->connection_text_container);
-  gtk_widget_hide (priv->hostkey_container);
-  gtk_widget_set_sensitive (priv->password_container, TRUE);
-  priv->awaiting_password_entry = priv->submitted_password = FALSE;
+  if (!priv->indisposed)
+    {
+      g_object_notify ((GObject*)self, "hostname");
+      vte_terminal_reset ((VteTerminal*)priv->terminal, TRUE, TRUE);
+      gtk_entry_set_text ((GtkEntry*)priv->password_entry, "");
+      reset_focus_state (self);
+      gtk_label_set_text ((GtkLabel*)priv->connection_text, "");
+      gtk_widget_show (priv->connection_text_container);
+      gtk_widget_hide (priv->hostkey_container);
+      gtk_widget_set_sensitive (priv->password_container, TRUE);
+      priv->awaiting_password_entry = priv->submitted_password = FALSE;
+    }
   g_debug ("reset state done");
 }
 
@@ -842,6 +846,8 @@ hotssh_tab_dispose (GObject *object)
   HotSshTab *self = HOTSSH_TAB (object);
   HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self);
 
+  priv->indisposed = TRUE;
+
   page_transition (self, HOTSSH_TAB_PAGE_NEW_CONNECTION);
 
   g_clear_object (&priv->host_completion);


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