1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

PixelPaint: Don't crash when cancel is pressed when saving a file

Previously, we were attempting to add an empty string to the most
recently open files list when no file was saved.
This commit is contained in:
Tim Ledbetter 2024-02-09 05:55:02 +00:00 committed by Jelle Raaijmakers
parent ecf41e13ad
commit ad62e433f0
3 changed files with 9 additions and 2 deletions

View file

@ -208,14 +208,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
auto* editor = current_image_editor();
VERIFY(editor);
editor->save_project_as();
GUI::Application::the()->set_most_recently_open_file(editor->path());
});
m_save_image_action = GUI::CommonActions::make_save_action([&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->save_project();
GUI::Application::the()->set_most_recently_open_file(editor->path());
});
file_menu->add_action(*m_new_image_action);
@ -1441,6 +1439,9 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
if (image_editor.active_tool())
image_editor.active_tool()->on_secondary_color_change(color);
};
image_editor.on_file_saved = [](ByteString const& filename) {
GUI::Application::the()->set_most_recently_open_file(filename);
};
if (image->layer_count())
image_editor.set_active_layer(&image->layer(0));