diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index a24c6b42261..a84ab531350 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -186,6 +186,11 @@ int main(int argc, char** argv) }); file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { + Optional open_path = GUI::FilePicker::get_open_filepath(window); + + if (!open_path.has_value()) + return; + if (window->is_modified()) { auto save_document_first_result = GUI::MessageBox::show(window, "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) @@ -194,11 +199,6 @@ int main(int argc, char** argv) return; } - Optional open_path = GUI::FilePicker::get_open_filepath(window); - - if (!open_path.has_value()) - return; - auto file = Core::File::construct(open_path.value()); if (!file->open(Core::OpenMode::ReadOnly) && file->error() != ENOENT) { GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: {}", open_path.value(), strerror(errno)), "Error", GUI::MessageBox::Type::Error);