mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
HackStudio: Don't crash when saving is denied on build
When running build while having unsaved changes in HackStudio, it asks whether you want to save the unsaved files with a separate dialog. When you click "Yes" to saving the files, but deny the save-file dialog, HackStudio would crash, since we were expecting there to be a file to save to. Now, we check whether a file was picked, and if not, we abort the build.
This commit is contained in:
parent
88cc019275
commit
02cc2e0f8f
3 changed files with 11 additions and 4 deletions
|
@ -71,18 +71,24 @@ void EditorWrapper::set_filename(DeprecatedString const& filename)
|
|||
update_diff();
|
||||
}
|
||||
|
||||
void EditorWrapper::save()
|
||||
bool EditorWrapper::save()
|
||||
{
|
||||
if (filename().is_empty()) {
|
||||
auto file_picker_action = GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
Optional<DeprecatedString> save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value());
|
||||
set_filename(save_path.value());
|
||||
if (save_path.has_value())
|
||||
set_filename(save_path.value());
|
||||
});
|
||||
file_picker_action->activate();
|
||||
|
||||
if (filename().is_empty())
|
||||
return false;
|
||||
}
|
||||
editor().write_to_file(filename()).release_value_but_fixme_should_propagate_errors();
|
||||
update_diff();
|
||||
editor().update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditorWrapper::update_diff()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue