[gnome-terminal] window: Exit early from screen-removed handler for now empty notebook
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] window: Exit early from screen-removed handler for now empty notebook
- Date: Mon, 21 Sep 2015 15:05:51 +0000 (UTC)
commit c8704ba3fef98d4acd59ec061566ff540b77c528
Author: Christian Persch <chpe gnome org>
Date: Sat Sep 19 16:58:34 2015 +0200
window: Exit early from screen-removed handler for now empty notebook
When the notebook is now empty, it's not necessary to change anything else
since the window will be closed right away. Since GtkNotebook doesn't send
the switch-page signal when removing the last and only screen in the notebook,
priv->active_tab will point to an already freed object, which causes a
crash when the window tries to update itself for the new active tab.
https://bugzilla.gnome.org/show_bug.cgi?id=755240
src/terminal-window.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/terminal-window.c b/src/terminal-window.c
index e065ac1..9127966 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3468,10 +3468,24 @@ mdi_screen_removed_cb (TerminalMdiContainer *container,
G_CALLBACK (screen_close_cb),
window);
+ /* We already got a switch-page signal whose handler sets the active tab to the
+ * new active tab, unless this screen was the only one in the notebook, so
+ * priv->active_tab is valid here.
+ */
+
+ pages = terminal_mdi_container_get_n_screens (container);
+ if (pages == 0)
+ {
+ priv->active_screen = NULL;
+
+ /* That was the last tab in the window; close it. */
+ gtk_widget_destroy (GTK_WIDGET (window));
+ return;
+ }
+
terminal_window_update_tabs_menu_sensitivity (window);
terminal_window_update_search_sensitivity (screen, window);
- pages = terminal_mdi_container_get_n_screens (container);
if (pages == 1)
{
TerminalScreen *active_screen = terminal_mdi_container_get_active_screen (container);
@@ -3479,10 +3493,6 @@ mdi_screen_removed_cb (TerminalMdiContainer *container,
terminal_window_update_size (window);
}
- else if (pages == 0)
- {
- gtk_widget_destroy (GTK_WIDGET (window));
- }
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]