From e9f5551450c9c745f2844a17407d544d624448ee Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 22 Aug 2022 09:53:51 +0200 Subject: [PATCH] #8563 - Fix icon scaling causing crash on startup. Ported from https://github.com/supermerill/SuperSlicer/commit/c8bb0a46b83e44e4d19fa401bc14fa0ed24c7411 --- src/slic3r/GUI/GLCanvas3D.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index dcc0d2db4..5815c6b33 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -6152,7 +6152,11 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() float noitems_width = top_tb_width - size * items_cnt; // width of separators and borders in top toolbars // calculate scale needed for items in all top toolbars - float new_h_scale = (cnv_size.get_width() - noitems_width) / (items_cnt * GLToolbar::Default_Icons_Size); + // the std::max() is there because on some Linux dialects/virtual machines this code is called when the canvas has not been properly initialized yet, + // leading to negative values for the scale. + // See: https://github.com/prusa3d/PrusaSlicer/issues/8563 + // https://github.com/supermerill/SuperSlicer/issues/854 + float new_h_scale = std::max((cnv_size.get_width() - noitems_width), 1.0f) / (items_cnt * GLToolbar::Default_Icons_Size); items_cnt = m_gizmos.get_selectable_icons_cnt() + 3; // +3 means a place for top and view toolbars and separators in gizmos toolbar