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

LibGUI: Handle Window::hide() during Application teardown better

If a window is being torn down during app shutdown, the global
application pointer may be nulled out already. So let's handle that
case gracefully in Window::hide().
This commit is contained in:
Andreas Kling 2021-01-30 14:02:06 +01:00
parent 5bf9999652
commit d9c5fdf5d5

View file

@ -196,15 +196,17 @@ void Window::hide()
} }
} }
bool app_has_visible_windows = false; if (auto* app = Application::the()) {
for (auto& window : *all_windows) { bool app_has_visible_windows = false;
if (window->is_visible()) { for (auto& window : *all_windows) {
app_has_visible_windows = true; if (window->is_visible()) {
break; app_has_visible_windows = true;
break;
}
} }
if (!app_has_visible_windows)
app->did_delete_last_window({});
} }
if (!app_has_visible_windows)
Application::the()->did_delete_last_window({});
} }
void Window::set_title(const StringView& title) void Window::set_title(const StringView& title)