Skip to content

Commit

Permalink
FIX: crash when setting negative thickness value on text tool
Browse files Browse the repository at this point in the history
github issue #1656

Change-Id: Ib77bdd3e4b2508c466d7122a9052d1d15d6bc4bb
  • Loading branch information
zhimin-zeng-bambulab authored and lanewei120 committed Jul 7, 2023
1 parent 611b281 commit 7a988c1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/slic3r/GUI/Gizmos/GLGizmoText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,12 @@ void GLGizmoText::on_render_input_window(float x, float y, float bottom_limit)
m_imgui->text(_L("Thickness"));
ImGui::SameLine(caption_size);
ImGui::PushItemWidth(list_width);
if(ImGui::InputFloat("###text_thickness", &m_thickness,0.0f, 0.0f, "%.2f"))
m_need_update_text = true;
float old_value = m_thickness;
ImGui::InputFloat("###text_thickness", &m_thickness, 0.0f, 0.0f, "%.2f");
if (m_thickness < 0.1f)
m_thickness = 0.1f;
if (old_value != m_thickness)
m_need_update_text = true;

const float slider_icon_width = m_imgui->get_slider_icon_size().x;
const float slider_width = list_width - 1.5 * slider_icon_width - space_size;
Expand Down Expand Up @@ -806,10 +808,12 @@ void GLGizmoText::on_render_input_window(float x, float y, float bottom_limit)
m_imgui->text(_L("Embeded\ndepth"));
ImGui::SameLine(caption_size);
ImGui::PushItemWidth(list_width);
if (ImGui::InputFloat("###text_embeded_depth", &m_embeded_depth, 0.0f, 0.0f, "%.2f"))
m_need_update_text = true;
old_value = m_embeded_depth;
ImGui::InputFloat("###text_embeded_depth", &m_embeded_depth, 0.0f, 0.0f, "%.2f");
if (m_embeded_depth < 0.f)
m_embeded_depth = 0.f;
if (old_value != m_embeded_depth)
m_need_update_text = true;

ImGui::AlignTextToFramePadding();
m_imgui->text(_L("Input text"));
Expand Down Expand Up @@ -1468,6 +1472,11 @@ void GLGizmoText::generate_text_volume(bool is_temp)

TextInfo text_info = get_text_info();
if (m_is_modify && m_need_update_text) {
if (m_object_idx == -1 || m_volume_idx == -1) {
BOOST_LOG_TRIVIAL(error) << boost::format("Text: selected object_idx = %1%, volume_idx = %2%") % m_object_idx % m_volume_idx;
return;
}

plater->take_snapshot("Modify Text");
const Selection &selection = m_parent.get_selection();
ModelObject * model_object = selection.get_model()->objects[m_object_idx];
Expand Down

0 comments on commit 7a988c1

Please sign in to comment.