1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:07:35 +00:00

AK: Make "foo"_string infallible

Stop worrying about tiny OOMs.

Work towards #20405.
This commit is contained in:
Andreas Kling 2023-08-07 11:12:38 +02:00
parent db2a8725c6
commit 34344120f2
181 changed files with 626 additions and 630 deletions

View file

@ -54,16 +54,16 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation
switch (m_operation) {
case FileOperation::Copy:
files_copied_label.set_text("Copying files..."_string.release_value_but_fixme_should_propagate_errors());
current_file_action_label.set_text("Copying: "_string.release_value_but_fixme_should_propagate_errors());
files_copied_label.set_text("Copying files..."_string);
current_file_action_label.set_text("Copying: "_string);
break;
case FileOperation::Move:
files_copied_label.set_text("Moving files..."_string.release_value_but_fixme_should_propagate_errors());
current_file_action_label.set_text("Moving: "_string.release_value_but_fixme_should_propagate_errors());
files_copied_label.set_text("Moving files..."_string);
current_file_action_label.set_text("Moving: "_string);
break;
case FileOperation::Delete:
files_copied_label.set_text("Deleting files..."_string.release_value_but_fixme_should_propagate_errors());
current_file_action_label.set_text("Deleting: "_string.release_value_but_fixme_should_propagate_errors());
files_copied_label.set_text("Deleting files..."_string);
current_file_action_label.set_text("Deleting: "_string);
break;
default:
VERIFY_NOT_REACHED();

View file

@ -182,7 +182,7 @@ ErrorOr<void> PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b
m_size_label = general_tab->find_descendant_of_type_named<GUI::Label>("size");
m_size_label->set_text(S_ISDIR(st.st_mode)
? TRY("Calculating..."_string)
? "Calculating..."_string
: TRY(String::from_deprecated_string(human_readable_size_long(st.st_size, UseThousandsSeparator::Yes))));
auto* owner = general_tab->find_descendant_of_type_named<GUI::Label>("owner");
@ -255,7 +255,7 @@ ErrorOr<void> PropertiesWindow::create_archive_tab(GUI::TabWidget& tab_widget, N
}
auto zip = maybe_zip.release_value();
auto tab = TRY(tab_widget.try_add_tab<GUI::Widget>(TRY("Archive"_string)));
auto tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Archive"_string));
TRY(tab->load_from_gml(properties_window_archive_tab_gml));
auto statistics = TRY(zip.calculate_statistics());
@ -365,19 +365,19 @@ ErrorOr<void> PropertiesWindow::create_font_tab(GUI::TabWidget& tab_widget, Nonn
String format_name;
switch (font_info.format) {
case FontInfo::Format::BitmapFont:
format_name = TRY("Bitmap Font"_string);
format_name = "Bitmap Font"_string;
break;
case FontInfo::Format::OpenType:
format_name = TRY("OpenType"_string);
format_name = "OpenType"_string;
break;
case FontInfo::Format::TrueType:
format_name = TRY("TrueType"_string);
format_name = "TrueType"_string;
break;
case FontInfo::Format::WOFF:
format_name = TRY("WOFF"_string);
format_name = "WOFF"_string;
break;
case FontInfo::Format::WOFF2:
format_name = TRY("WOFF2"_string);
format_name = "WOFF2"_string;
break;
}
tab->find_descendant_of_type_named<GUI::Label>("font_format")->set_text(format_name);
@ -438,11 +438,11 @@ ErrorOr<void> PropertiesWindow::create_image_tab(GUI::TabWidget& tab_widget, Non
if (auto embedded_icc_bytes = TRY(image_decoder->icc_data()); embedded_icc_bytes.has_value()) {
auto icc_profile_or_error = Gfx::ICC::Profile::try_load_from_externally_owned_memory(embedded_icc_bytes.value());
if (icc_profile_or_error.is_error()) {
hide_icc_group(TRY("Present but invalid"_string));
hide_icc_group("Present but invalid"_string);
} else {
auto icc_profile = icc_profile_or_error.release_value();
tab->find_descendant_of_type_named<GUI::Label>("image_has_icc_profile")->set_text(TRY("See below"_string));
tab->find_descendant_of_type_named<GUI::Label>("image_has_icc_profile")->set_text("See below"_string);
tab->find_descendant_of_type_named<GUI::Label>("image_icc_profile")->set_text(icc_profile->tag_string_data(Gfx::ICC::profileDescriptionTag).value_or({}));
tab->find_descendant_of_type_named<GUI::Label>("image_icc_copyright")->set_text(icc_profile->tag_string_data(Gfx::ICC::copyrightTag).value_or({}));
tab->find_descendant_of_type_named<GUI::Label>("image_icc_color_space")->set_text(TRY(String::from_utf8(data_color_space_name(icc_profile->data_color_space()))));
@ -468,7 +468,7 @@ ErrorOr<void> PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu
if (auto handler = document->security_handler(); handler && !handler->has_user_password()) {
// FIXME: Show a password dialog, once we've switched to lazy-loading
auto tab = TRY(tab_widget.try_add_tab<GUI::Label>("PDF"_short_string));
tab->set_text(TRY("PDF is password-protected."_string));
tab->set_text("PDF is password-protected."_string);
return {};
}

View file

@ -362,7 +362,7 @@ bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, DirectoryView c
if (current_file_launch_handlers.size() > 1) {
added_open_menu_items = true;
auto& file_open_with_menu = menu->add_submenu("Open with"_string.release_value_but_fixme_should_propagate_errors());
auto& file_open_with_menu = menu->add_submenu("Open with"_string);
for (auto& handler : current_file_launch_handlers) {
if (handler == default_file_handler)
continue;
@ -476,7 +476,7 @@ ErrorOr<int> run_in_desktop_mode()
paste_action->set_enabled(data_type == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0);
};
auto desktop_view_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View"_string)));
auto desktop_view_context_menu = TRY(GUI::Menu::try_create("Directory View"_string));
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)), [&](auto&) {
auto paths = directory_view->selected_file_paths();
@ -518,7 +518,7 @@ ErrorOr<int> run_in_desktop_mode()
TRY(desktop_view_context_menu->try_add_separator());
TRY(desktop_view_context_menu->try_add_action(display_properties_action));
auto desktop_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View Directory"_string)));
auto desktop_context_menu = TRY(GUI::Menu::try_create("Directory View Directory"_string));
TRY(desktop_context_menu->try_add_action(file_manager_action));
TRY(desktop_context_menu->try_add_action(open_terminal_action));
@ -541,7 +541,7 @@ ErrorOr<int> run_in_desktop_mode()
if (node.is_directory()) {
desktop_context_menu->popup(event.screen_position(), file_manager_action);
} else {
file_context_menu = GUI::Menu::construct("Directory View File"_string.release_value_but_fixme_should_propagate_errors());
file_context_menu = GUI::Menu::construct("Directory View File"_string);
bool added_open_menu_items = add_launch_handler_actions_to_menu(file_context_menu, directory_view, node.full_path(), file_context_menu_action_default_action, current_file_handlers);
if (added_open_menu_items)
@ -685,9 +685,9 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
directory_view->refresh();
};
auto directory_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View Directory"_string)));
auto directory_view_context_menu = TRY(GUI::Menu::try_create(TRY("Directory View"_string)));
auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create(TRY("Tree View Directory"_string)));
auto directory_context_menu = TRY(GUI::Menu::try_create("Directory View Directory"_string));
auto directory_view_context_menu = TRY(GUI::Menu::try_create("Directory View"_string));
auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create("Tree View Directory"_string));
auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"sv)), [&](GUI::Action const&) {
directory_view->open_parent_directory();
@ -1205,7 +1205,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
folder_specific_paste_action->set_enabled(should_get_enabled);
directory_context_menu->popup(event.screen_position(), directory_open_action);
} else {
file_context_menu = GUI::Menu::construct("Directory View File"_string.release_value_but_fixme_should_propagate_errors());
file_context_menu = GUI::Menu::construct("Directory View File"_string);
bool added_launch_file_handlers = add_launch_handler_actions_to_menu(file_context_menu, directory_view, node.full_path(), file_context_menu_action_default_action, current_file_handlers);
if (added_launch_file_handlers)