From d7ff2c5b86546fb7d7bebde7afeb03b6f67199e4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 26 Jul 2019 16:13:59 +0200 Subject: LibGUI: GDialog should close its nested event loop on window close. Make GWindow::close() so we can override it in GDialog and quit from the internal event loop when the window manager tells us to close ourselves. The dialog will return GDialog::ExecCancel in these situations. --- Libraries/LibGUI/GDialog.cpp | 7 +++++++ Libraries/LibGUI/GDialog.h | 2 ++ Libraries/LibGUI/GWindow.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'Libraries/LibGUI') diff --git a/Libraries/LibGUI/GDialog.cpp b/Libraries/LibGUI/GDialog.cpp index 7438e41b2e..eaa3359f39 100644 --- a/Libraries/LibGUI/GDialog.cpp +++ b/Libraries/LibGUI/GDialog.cpp @@ -40,3 +40,10 @@ void GDialog::done(int result) dbgprintf("%s: quit event loop with result %d\n", class_name(), result); m_event_loop->quit(result); } + +void GDialog::close() +{ + GWindow::close(); + m_event_loop->quit(ExecCancel); +} + diff --git a/Libraries/LibGUI/GDialog.h b/Libraries/LibGUI/GDialog.h index a0e9a2cb46..6b3bbb7f04 100644 --- a/Libraries/LibGUI/GDialog.h +++ b/Libraries/LibGUI/GDialog.h @@ -19,6 +19,8 @@ public: int result() const { return m_result; } void done(int result); + virtual void close() override; + protected: explicit GDialog(CObject* parent); diff --git a/Libraries/LibGUI/GWindow.h b/Libraries/LibGUI/GWindow.h index e8b50ed13a..a0ec5f8542 100644 --- a/Libraries/LibGUI/GWindow.h +++ b/Libraries/LibGUI/GWindow.h @@ -82,7 +82,7 @@ public: void show(); void hide(); - void close(); + virtual void close(); void move_to_front(); void start_wm_resize(); -- cgit v1.2.3