From 98f2dd4d93ca73977becad3c55394de15ac62914 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Fri, 28 Jun 2024 23:06:58 +0100 Subject: [PATCH] UI/Qt: Ignore tab bar middle clicks if the user didn't click on a tab This prevents a segfault that would occur when middle clicking to close a tab if only 1 tab was open. --- Ladybird/Qt/BrowserWindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index 9318da6d4c5a5..ad0cd5dd71b15 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -1156,8 +1156,10 @@ bool BrowserWindow::eventFilter(QObject* obj, QEvent* event) if (mouse_event->button() == Qt::MouseButton::MiddleButton) { if (obj == m_tabs_container) { auto const tab_index = m_tabs_container->tabBar()->tabAt(mouse_event->pos()); - close_tab(tab_index); - return true; + if (tab_index != -1) { + close_tab(tab_index); + return true; + } } } }