diff --git a/Userland/Applications/PDFViewer/OutlineModel.cpp b/Userland/Applications/PDFViewer/OutlineModel.cpp index 125714bc6f4..5414d7f4425 100644 --- a/Userland/Applications/PDFViewer/OutlineModel.cpp +++ b/Userland/Applications/PDFViewer/OutlineModel.cpp @@ -7,16 +7,17 @@ #include "OutlineModel.h" #include -NonnullRefPtr OutlineModel::create(NonnullRefPtr const& outline) +ErrorOr> OutlineModel::create(NonnullRefPtr const& outline) { - return adopt_ref(*new OutlineModel(outline)); + auto outline_model = adopt_ref(*new OutlineModel(outline)); + outline_model->m_closed_item_icon.set_bitmap_for_size(16, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png"sv))); + outline_model->m_open_item_icon.set_bitmap_for_size(16, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv))); + return outline_model; } OutlineModel::OutlineModel(NonnullRefPtr const& outline) : m_outline(outline) { - m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png"sv).release_value_but_fixme_should_propagate_errors()); - m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); } void OutlineModel::set_index_open_state(const GUI::ModelIndex& index, bool is_open) diff --git a/Userland/Applications/PDFViewer/OutlineModel.h b/Userland/Applications/PDFViewer/OutlineModel.h index 50cf4069663..3ecb57f6f79 100644 --- a/Userland/Applications/PDFViewer/OutlineModel.h +++ b/Userland/Applications/PDFViewer/OutlineModel.h @@ -12,7 +12,7 @@ class OutlineModel final : public GUI::Model { public: - static NonnullRefPtr create(NonnullRefPtr const& outline); + static ErrorOr> create(NonnullRefPtr const& outline); void set_index_open_state(const GUI::ModelIndex& index, bool is_open); diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index e1265d1002e..eb6fc348ce6 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -376,11 +376,11 @@ PDF::PDFErrorOr PDFViewerWidget::try_open_file(Core::File& file) if (document->outline()) { auto outline = document->outline(); - m_sidebar->set_outline(outline.release_nonnull()); + TRY(m_sidebar->set_outline(outline.release_nonnull())); m_sidebar->set_visible(true); m_sidebar_open = true; } else { - m_sidebar->set_outline({}); + TRY(m_sidebar->set_outline({})); m_sidebar->set_visible(false); m_sidebar_open = false; } diff --git a/Userland/Applications/PDFViewer/SidebarWidget.h b/Userland/Applications/PDFViewer/SidebarWidget.h index 5d0657c726d..3e83d01e68e 100644 --- a/Userland/Applications/PDFViewer/SidebarWidget.h +++ b/Userland/Applications/PDFViewer/SidebarWidget.h @@ -16,15 +16,16 @@ class SidebarWidget final : public GUI::Widget { public: ~SidebarWidget() override = default; - void set_outline(RefPtr outline) + ErrorOr set_outline(RefPtr outline) { if (outline) { - m_model = OutlineModel::create(outline.release_nonnull()); + m_model = TRY(OutlineModel::create(outline.release_nonnull())); m_outline_tree_view->set_model(m_model); } else { m_model = RefPtr {}; m_outline_tree_view->set_model({}); } + return {}; } private: