diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 53487bbdf6..96f4df6ae2 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -125,6 +125,7 @@ GLGizmoEmboss::GLGizmoEmboss(GLCanvas3D &parent) , m_rotate_gizmo(parent, GLGizmoRotate::Axis::Z) // grab id = 2 (Z axis) , m_font_manager(m_imgui->get_glyph_ranges()) , m_update_job_cancel(nullptr) + , m_allow_update_rendered_font(false) { m_rotate_gizmo.set_group_id(0); // TODO: add suggestion to use https://fontawesome.com/ @@ -1332,6 +1333,7 @@ void GLGizmoEmboss::draw_font_list() const char * selected = (!actual_face_name.empty()) ? actual_face_name.ToUTF8().data() : " --- "; wxString del_facename; + static bool was_opened = false; if (ImGui::BeginCombo("##font_selector", selected)) { if (!m_face_names.is_init) init_face_names(); init_texture(); @@ -1361,7 +1363,9 @@ void GLGizmoEmboss::draw_font_list() m_face_names.encoding, m_face_names.texture_id, index, - m_gui_cfg->face_name_size}; + m_gui_cfg->face_name_size, + &m_allow_update_rendered_font + }; auto job = std::make_unique(std::move(data)); auto& worker = wxGetApp().plater()->get_ui_job_worker(); queue_job(worker, std::move(job)); @@ -1379,8 +1383,10 @@ void GLGizmoEmboss::draw_font_list() static_cast(m_face_names.names.size())); #endif // SHOW_FONT_COUNT ImGui::EndCombo(); - } else { + m_allow_update_rendered_font = true; + } else if (m_allow_update_rendered_font) { // free texture and set id to zero + m_allow_update_rendered_font = false; glsafe(::glDeleteTextures(1, &m_face_names.texture_id)); m_face_names.texture_id = 0; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp index 44dfdeb05c..4ca7bcbd56 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.hpp @@ -242,6 +242,9 @@ private: // cancel for previous update of volume to cancel finalize part std::shared_ptr> m_update_job_cancel; + // cancel for rendering font name + bool m_allow_update_rendered_font; + // actual volume ModelVolume *m_volume; diff --git a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp index 6bcedffc06..ba7b381885 100644 --- a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp @@ -95,6 +95,7 @@ void CreateFontImageJob::process(Ctl &ctl) void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &) { if (canceled) return; + if (! (* m_input.allow_update)) return; // upload texture on GPU const GLenum target = GL_TEXTURE_2D; diff --git a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.hpp b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.hpp index 7ea6fe0e70..2eef33017f 100644 --- a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.hpp +++ b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.hpp @@ -29,6 +29,9 @@ struct FontImageData // And Limit for width Vec2i size; // in px + // cancel, can be used only in finalize + bool *allow_update; + // bigger value create darker image // divide value 255 unsigned char gray_level = 5;