1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:37:45 +00:00

WindowServer: Clean up any menu objects on process exit.

..and now that this works, implement the Quit menu action in Terminal. :^)
This commit is contained in:
Andreas Kling 2019-02-12 10:41:09 +01:00
parent f311d0f353
commit 4b8133e925
10 changed files with 76 additions and 16 deletions

View file

@ -2133,6 +2133,7 @@ void Process::finalize()
{
ASSERT(current == g_finalizer);
destroy_all_menus();
destroy_all_windows();
m_fds.clear();
m_tty = nullptr;

View file

@ -244,6 +244,7 @@ public:
static void initialize();
static void initialize_gui_statics();
int make_window_id();
void destroy_all_menus();
void destroy_all_windows();
void crash() NORETURN;
@ -419,6 +420,7 @@ private:
Vector<GUI_Event> m_gui_events;
Lock m_gui_events_lock;
int m_next_window_id { 1 };
bool m_has_created_menus { false };
dword m_wakeup_requested { false };
bool m_has_used_fpu { false };

View file

@ -257,6 +257,13 @@ int Process::gui$set_global_cursor_tracking_enabled(int window_id, bool enabled)
return 0;
}
void Process::destroy_all_menus()
{
if (!m_has_created_menus)
return;
WSWindowManager::the().destroy_all_menus(*this);
}
void Process::destroy_all_windows()
{
for (auto& it : m_windows) {
@ -267,7 +274,6 @@ void Process::destroy_all_windows()
m_windows.clear();
}
DisplayInfo Process::set_video_resolution(int width, int height)
{
DisplayInfo info;
@ -288,6 +294,7 @@ DisplayInfo Process::set_video_resolution(int width, int height)
int Process::gui$menubar_create()
{
m_has_created_menus = true;
return WSWindowManager::the().api$menubar_create();
}
@ -305,6 +312,7 @@ int Process::gui$menu_create(const char* name)
{
if (!validate_read_str(name))
return -EFAULT;
m_has_created_menus = true;
return WSWindowManager::the().api$menu_create(String(name));
}