From 343de324db3e0ab3b60cd31fa521d8c855fb4d04 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 19 Jan 2024 16:55:30 +0000 Subject: [PATCH] LibGUI: Don't update the recent files if we haven't created them yet We previously assumed that `set_most_recently_open_file()` would only be called after `Menu::add_recent_files_list()` had been called, and would crash if we hadn't called it yet. This stops the crash. We're fine to do this, because we always call `update_recent_file_actions()` in `register_recent_file_actions()` so it's guaranteed to be up to date when we do need it. --- Userland/Libraries/LibGUI/Application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 7d75e9a503..f59300d03c 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -399,7 +399,8 @@ void Application::set_most_recently_open_file(ByteString new_path) path); } - update_recent_file_actions(); + if (!m_recent_file_actions.is_empty()) + update_recent_file_actions(); } }