Skip to content

Commit

Permalink
UI/Qt: Ignore tab bar middle clicks if the user didn't click on a tab
Browse files Browse the repository at this point in the history
This prevents a segfault that would occur when middle clicking to close
a tab if only 1 tab was open.
  • Loading branch information
tcl3 committed Jun 28, 2024
1 parent d9470d6 commit 98f2dd4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Ladybird/Qt/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 98f2dd4

Please sign in to comment.