#8563 - Fix icon scaling causing crash on startup. Ported from c8bb0a46b8

This commit is contained in:
enricoturri1966 2022-08-22 09:53:51 +02:00
parent f586a3e727
commit e9f5551450

View File

@ -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 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 // 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 items_cnt = m_gizmos.get_selectable_icons_cnt() + 3; // +3 means a place for top and view toolbars and separators in gizmos toolbar