1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

AK+Everywhere: Remove the null state of DeprecatedString

This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
This commit is contained in:
Ali Mohammad Pur 2023-10-10 15:00:58 +03:30 committed by Ali Mohammad Pur
parent daf6d8173c
commit aeee98b3a1
189 changed files with 597 additions and 652 deletions

View file

@ -48,9 +48,10 @@ ErrorOr<Optional<String>> FilePicker::get_filepath(Badge<FileSystemAccessServer:
ConnectionToWindowServer::the().set_window_parent_from_client(window_server_client_id, parent_window_id, picker->window_id());
if (picker->exec() == ExecResult::OK) {
auto file_path = TRY(String::from_deprecated_string(picker->selected_file()));
if (file_path.is_empty())
auto file_path = TRY(picker->selected_file().map([](auto& v) { return String::from_deprecated_string(v); }));
if (file_path.has_value() && file_path->is_empty())
return Optional<String> {};
return file_path;
}
return Optional<String> {};
@ -60,17 +61,12 @@ Optional<DeprecatedString> FilePicker::get_open_filepath(Window* parent_window,
{
auto picker = FilePicker::construct(parent_window, folder ? Mode::OpenFolder : Mode::Open, ""sv, path, screen_position, move(allowed_file_types));
if (!window_title.is_null())
if (!window_title.is_empty())
picker->set_title(window_title);
if (picker->exec() == ExecResult::OK) {
DeprecatedString file_path = picker->selected_file();
if (picker->exec() == ExecResult::OK)
return picker->selected_file();
if (file_path.is_null())
return {};
return file_path;
}
return {};
}
@ -78,14 +74,8 @@ Optional<DeprecatedString> FilePicker::get_save_filepath(Window* parent_window,
{
auto picker = FilePicker::construct(parent_window, Mode::Save, DeprecatedString::formatted("{}.{}", title, extension), path, screen_position);
if (picker->exec() == ExecResult::OK) {
DeprecatedString file_path = picker->selected_file();
if (file_path.is_null())
return {};
return file_path;
}
if (picker->exec() == ExecResult::OK)
return picker->selected_file();
return {};
}