From 59b583329ab9b0b820941e6edf0d8696e7870429 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 8 Aug 2023 18:42:18 -0400 Subject: [PATCH] Ladybird: Close the current tab even if we're closing the window Currently, if the JS console is open and tied to the last opened tab in the browser window, it will prevent the main process from exiting when the last tab is closed. This change explicitly closes that tab before closing the window (if it's the last tab), allowing Qt to delete the Tab object. --- Ladybird/Qt/BrowserWindow.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index 1ec4adcae1c..625cf1bf4a5 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -521,11 +521,10 @@ void BrowserWindow::open_file() void BrowserWindow::close_current_tab() { - auto count = m_tabs_container->count() - 1; - if (!count) + close_tab(m_tabs_container->currentIndex()); + + if (m_tabs_container->count() == 0) close(); - else - close_tab(m_tabs_container->currentIndex()); } int BrowserWindow::tab_index(Tab* tab)