From 59fd8e1011df2e41a6e1578de93ad03d003158d9 Mon Sep 17 00:00:00 2001
From: Andre Miranda <andreldm@xfce.org>
Date: Wed, 16 Dec 2020 19:48:49 -0300
Subject: [PATCH] Avoid crashes when closing thunar with ctrl+w (#336)

---
 thunar/thunar-window.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index b38a1e706..ea3affc6e 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -2537,7 +2537,9 @@ static void
 thunar_window_action_close_tab (ThunarWindow *window,
                                 GtkWidget    *menu_item)
 {
-  if (window->view != NULL)
+  if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) == 1)
+    gtk_widget_destroy (GTK_WIDGET (window));
+  else if (window->view != NULL)
     gtk_widget_destroy (window->view);
 }
 
-- 
GitLab