summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-30 14:02:06 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-30 14:03:53 +0100
commitd9c5fdf5d50dca0749bbcc0015c8f5285d384336 (patch)
tree613fc78e8d28e11b0b7a6755073625fc37df688d /Userland/Libraries/LibGUI
parent5bf999965242ae1cca4c0fad1f200859af71ee56 (diff)
downloadserenity-d9c5fdf5d50dca0749bbcc0015c8f5285d384336.zip
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().
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/Window.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp
index a3c3d855f8..c2e684c237 100644
--- a/Userland/Libraries/LibGUI/Window.cpp
+++ b/Userland/Libraries/LibGUI/Window.cpp
@@ -196,15 +196,17 @@ void Window::hide()
}
}
- bool app_has_visible_windows = false;
- for (auto& window : *all_windows) {
- if (window->is_visible()) {
- app_has_visible_windows = true;
- break;
+ if (auto* app = Application::the()) {
+ bool app_has_visible_windows = false;
+ for (auto& window : *all_windows) {
+ if (window->is_visible()) {
+ 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)