diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 18:53:17 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 18:53:17 +0200 |
commit | 870bc2a4d1a86b9c889461a3981ee359ff45c15c (patch) | |
tree | e109b41f2afca957dd27c9cbf20ef455b8174273 /Libraries/LibGUI/GWindow.cpp | |
parent | 7584480f628c878e107bf66770e988bedb8cd6c5 (diff) | |
download | serenity-870bc2a4d1a86b9c889461a3981ee359ff45c15c.zip |
LibGUI: Get rid of GWindow's destroy-on-close mechanism
Since we're moving to a world of ref-counting, we can't have weird
behaviors like "windows delete themselves when you close them."
The "close app when there are no more windows" mechanism is moved
to GWindow::hide(). Now, we close the app when it has no more
windows on screen.
Diffstat (limited to 'Libraries/LibGUI/GWindow.cpp')
-rw-r--r-- | Libraries/LibGUI/GWindow.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Libraries/LibGUI/GWindow.cpp b/Libraries/LibGUI/GWindow.cpp index 1c340ae42c..59fe675d07 100644 --- a/Libraries/LibGUI/GWindow.cpp +++ b/Libraries/LibGUI/GWindow.cpp @@ -38,15 +38,11 @@ GWindow::~GWindow() { all_windows.remove(this); hide(); - if (all_windows.is_empty()) { - GApplication::the().did_delete_last_window({}); - } } void GWindow::close() { - if (should_destroy_on_close()) - delete_later(); + hide(); } void GWindow::move_to_front() @@ -104,6 +100,16 @@ void GWindow::hide() m_pending_paint_event_rects.clear(); m_back_bitmap = nullptr; m_front_bitmap = nullptr; + + 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) + GApplication::the().did_delete_last_window({}); } void GWindow::set_title(const StringView& title) |