From 745a45408143af16e1dbf5f74c7c405dd9762472 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 4 Apr 2023 10:23:47 +0200 Subject: [PATCH] Follow-up of 81cebe5be3903e3cdcaa75f689dbdffaf7891b21 - Fixed crash at startup when any of the svg files used as icon into imgui dialog (and/or splash screen icon) is renamed/removed. --- src/slic3r/GUI/GUI_App.cpp | 6 +++++- src/slic3r/GUI/ImGuiWrapper.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 01288867a..dc4bb17e8 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -216,7 +216,11 @@ public: // load bitmap for logo BitmapCache bmp_cache; int logo_size = lround(width * 0.25); - wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().logo_name(), logo_size, logo_size); + wxBitmap* logo_bmp_ptr = bmp_cache.load_svg(wxGetApp().logo_name(), logo_size, logo_size); + if (logo_bmp_ptr == nullptr) + return; + + wxBitmap logo_bmp = *logo_bmp_ptr; wxCoord margin = int(m_scale * 20); diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 73a4cc439..8e3d2ac5f 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -1684,6 +1684,10 @@ void ImGuiWrapper::init_font(bool compress) assert(rect->Width == icon_sz); assert(rect->Height == icon_sz); std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz); + if (raw_data.empty()) { + rect_id++; + continue; + } const ImU32* pIn = (ImU32*)raw_data.data(); for (int y = 0; y < icon_sz; y++) { ImU32* pOut = (ImU32*)pixels + (rect->Y + y) * width + (rect->X); @@ -1720,6 +1724,10 @@ void ImGuiWrapper::init_font(bool compress) assert(rect->Width == icon_sz); assert(rect->Height == icon_sz); std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz); + if (raw_data.empty()) { + rect_id++; + continue; + } const ImU32* pIn = (ImU32*)raw_data.data(); for (int y = 0; y < icon_sz; y++) { ImU32* pOut = (ImU32*)pixels + (rect->Y + y) * width + (rect->X);