LibGfx: Use "try_" prefix for static factory functions

Also mark them as [[nodiscard]].
This commit is contained in:
Andreas Kling 2021-07-21 18:02:15 +02:00
parent f0409081f5
commit c7d891765c
Notes: sideshowbarker 2024-07-18 08:38:30 +09:00
131 changed files with 422 additions and 421 deletions

View file

@ -32,7 +32,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
unstaged_header.set_layout<GUI::HorizontalBoxLayout>();
auto& refresh_button = unstaged_header.add<GUI::Button>();
refresh_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"));
refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"));
refresh_button.set_fixed_size(16, 16);
refresh_button.set_tooltip("refresh");
refresh_button.on_click = [this](int) { refresh(); };
@ -43,7 +43,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
unstaged_header.set_fixed_height(20);
m_unstaged_files = unstaged.add<GitFilesView>(
[this](const auto& file) { stage_file(file); },
Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png").release_nonnull());
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_nonnull());
m_unstaged_files->on_selection_change = [this] {
const auto& index = m_unstaged_files->selection().first();
const auto& selected = index.data().as_string();
@ -57,7 +57,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
staged_header.set_layout<GUI::HorizontalBoxLayout>();
auto& commit_button = staged_header.add<GUI::Button>();
commit_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/commit.png"));
commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png"));
commit_button.set_fixed_size(16, 16);
commit_button.set_tooltip("commit");
commit_button.on_click = [this](int) { commit(); };
@ -68,7 +68,7 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
staged_header.set_fixed_height(20);
m_staged_files = staged.add<GitFilesView>(
[this](const auto& file) { unstage_file(file); },
Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png").release_nonnull());
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_nonnull());
}
bool GitWidget::initialize()