From 086fcd4e44ed13d18960a8a3aa89ba1ab62da192 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Wed, 30 Mar 2022 00:45:36 +0200 Subject: [PATCH] 3DFileViewer: Do not abort model loading when texture is missing --- Userland/Applications/3DFileViewer/main.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index 240e725eb1..d91163c4a6 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -299,13 +299,12 @@ bool GLContextWidget::load_file(Core::File& file) texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); } else { auto response = FileSystemAccessClient::Client::the().try_request_file(window(), builder.string_view(), Core::OpenMode::ReadOnly); - if (response.is_error()) - return false; - - auto texture_file = response.value(); - auto bitmap_or_error = Gfx::Bitmap::try_load_from_fd_and_close(texture_file->leak_fd(), texture_file->filename()); - if (!bitmap_or_error.is_error()) - texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); + if (!response.is_error()) { + auto texture_file = response.value(); + auto bitmap_or_error = Gfx::Bitmap::try_load_from_fd_and_close(texture_file->leak_fd(), texture_file->filename()); + if (!bitmap_or_error.is_error()) + texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); + } } GLuint tex; @@ -331,8 +330,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio thread recvfd sendfd rpath unix")); TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw")); - TRY(Core::System::unveil("/home/anon/Documents/3D Models/teapot.obj", "r")); - TRY(Core::System::unveil("/home/anon/Documents/3D Models/teapot.bmp", "r")); + TRY(Core::System::unveil("/home/anon/Documents/3D Models", "r")); TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr));