Skip to content

Commit

Permalink
Fix icon scaling causing crash on startup
Browse files Browse the repository at this point in the history
Icons can get scaled even if the window is not yet fully initialised, in
which case they ended up with a negative scale.

Potentially related to #854

Revert "Add a linux startup crash fix."
This reverts commit 34ff5c0.
  • Loading branch information
LucaRood authored and supermerill committed Feb 13, 2022
1 parent 650c13e commit c8bb0a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/slic3r/GUI/GLCanvas3D.cpp
Expand Up @@ -5266,8 +5266,8 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const
int items_cnt = m_main_toolbar.get_visible_items_cnt() + m_undoredo_toolbar.get_visible_items_cnt() + collapse_toolbar.get_visible_items_cnt();
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);
// calculate scale needed for items in all top toolbars (make sure the size is positive even if `cnv_size` is less than `noitems_width`)
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

Expand Down
4 changes: 0 additions & 4 deletions src/slic3r/GUI/GUI_App.cpp
Expand Up @@ -1199,10 +1199,6 @@ float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const

if (is_limited && int_val < 50)
int_val = 50;
else if (int_val < 1) {
int_val = 10; //buggy code? issue supermerill/superslicer#854
assert(false);
}

return 0.01f * int_val * icon_sc;
}
Expand Down

0 comments on commit c8bb0a4

Please sign in to comment.