From 51e655f9033d4c14119ab2264735545d3cd85a0a Mon Sep 17 00:00:00 2001 From: Brandon Scott Date: Fri, 25 Oct 2019 00:23:35 -0500 Subject: [PATCH] LibGUI: Added window creation callback to GApplication/GWindow Added a window creation callback to GApplication that gets called by GWindow which will reset any pending exit request in the CEventLoop. This is to prevent a bug which prevents your application from starting up if you had a message box or other dialog before showing your main application form. The bug was triggered by there being no more visible windows which was triggering a premature quit(). --- Libraries/LibGUI/GApplication.cpp | 6 ++++++ Libraries/LibGUI/GApplication.h | 1 + Libraries/LibGUI/GWindow.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/Libraries/LibGUI/GApplication.cpp b/Libraries/LibGUI/GApplication.cpp index ef671eb032..9bdd7af840 100644 --- a/Libraries/LibGUI/GApplication.cpp +++ b/Libraries/LibGUI/GApplication.cpp @@ -119,6 +119,12 @@ void GApplication::hide_tooltip() } } +void GApplication::did_create_window(Badge) +{ + if (m_event_loop->was_exit_requested()) + m_event_loop->unquit(); +} + void GApplication::did_delete_last_window(Badge) { if (m_quit_when_last_window_deleted) diff --git a/Libraries/LibGUI/GApplication.h b/Libraries/LibGUI/GApplication.h index 630994561d..ad8e57e76e 100644 --- a/Libraries/LibGUI/GApplication.h +++ b/Libraries/LibGUI/GApplication.h @@ -33,6 +33,7 @@ public: bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; } void set_quit_when_last_window_deleted(bool b) { m_quit_when_last_window_deleted = b; } + void did_create_window(Badge); void did_delete_last_window(Badge); const String& invoked_as() const { return m_invoked_as; } diff --git a/Libraries/LibGUI/GWindow.cpp b/Libraries/LibGUI/GWindow.cpp index c05f7fe4b4..7620f30acc 100644 --- a/Libraries/LibGUI/GWindow.cpp +++ b/Libraries/LibGUI/GWindow.cpp @@ -84,6 +84,7 @@ void GWindow::show() apply_icon(); reified_windows.set(m_window_id, this); + GApplication::the().did_create_window({}); update(); }