Bladeren bron

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().
Brandon Scott 5 jaren geleden
bovenliggende
commit
51e655f903
3 gewijzigde bestanden met toevoegingen van 8 en 0 verwijderingen
  1. 6 0
      Libraries/LibGUI/GApplication.cpp
  2. 1 0
      Libraries/LibGUI/GApplication.h
  3. 1 0
      Libraries/LibGUI/GWindow.cpp

+ 6 - 0
Libraries/LibGUI/GApplication.cpp

@@ -119,6 +119,12 @@ void GApplication::hide_tooltip()
     }
 }
 
+void GApplication::did_create_window(Badge<GWindow>)
+{
+    if (m_event_loop->was_exit_requested())
+        m_event_loop->unquit();
+}
+
 void GApplication::did_delete_last_window(Badge<GWindow>)
 {
     if (m_quit_when_last_window_deleted)

+ 1 - 0
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<GWindow>);
     void did_delete_last_window(Badge<GWindow>);
 
     const String& invoked_as() const { return m_invoked_as; }

+ 1 - 0
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();
 }