1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

LibGUI+Browser: Fix crash when activating a "Tab n" action

Previously we would try setting the tab index regardless if that tab
actually existed, resulting in Browser crashing by either pressing
Control + N or using the CommandPalette.
This commit is contained in:
networkException 2022-06-05 13:08:09 +02:00 committed by Linus Groh
parent 971d6ce16f
commit 52ee5026ea
2 changed files with 4 additions and 1 deletions

View file

@ -111,8 +111,10 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
m_tab_widget->activate_previous_tab();
};
for (int i = 0; i <= 7; ++i) {
for (size_t i = 0; i <= 7; ++i) {
m_window_actions.on_tabs.append([this, i] {
if (i >= m_tab_widget->tab_count())
return;
m_tab_widget->set_tab_index(i);
});
}

View file

@ -29,6 +29,7 @@ public:
bool has_vertical_tabs() const { return m_tab_position == TabPosition::Left || m_tab_position == TabPosition::Right; }
Optional<size_t> active_tab_index() const;
size_t tab_count() { return m_tabs.size(); }
Widget* active_widget() { return m_active_widget.ptr(); }
Widget const* active_widget() const { return m_active_widget.ptr(); }