diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 8d4aa9e18..5a39d8033 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -601,7 +601,9 @@ void GLGizmoEmboss::on_set_state() return; } m_volume = nullptr; - + // Store order and last activ index into app.ini + // TODO: what to do when can't store into file? + m_style_manager.store_styles_to_app_config(false); remove_notification_not_valid_font(); } else if (GLGizmoBase::m_state == GLGizmoBase::On) { if (!m_gui_cfg.has_value()) initialize(); diff --git a/src/slic3r/Utils/EmbossStyleManager.cpp b/src/slic3r/Utils/EmbossStyleManager.cpp index 24677d006..0c4ab15f5 100644 --- a/src/slic3r/Utils/EmbossStyleManager.cpp +++ b/src/slic3r/Utils/EmbossStyleManager.cpp @@ -25,10 +25,6 @@ EmbossStyleManager::EmbossStyleManager(const ImWchar *language_glyph_range) EmbossStyleManager::~EmbossStyleManager() { clear_imgui_font(); free_style_images(); - store_styles_to_app_config(false, false); - if (m_app_config != nullptr && - m_last_style_index != std::numeric_limits::max()) - EmbossStylesSerializable::store_style_index(*m_app_config, m_last_style_index); } void EmbossStyleManager::init(AppConfig *app_config, const EmbossStyles &default_styles) @@ -90,8 +86,14 @@ bool EmbossStyleManager::store_styles_to_app_config(bool use_modification, m_style_cache.stored_wx_font = m_style_cache.wx_font; } } + if (store_activ_index) - EmbossStylesSerializable::store_style_index(*m_app_config, m_style_cache.style_index); + { + size_t style_index = exist_stored_style() ? + m_style_cache.style_index : + m_last_style_index; + EmbossStylesSerializable::store_style_index(*m_app_config, style_index); + } EmbossStyles styles; styles.reserve(m_style_items.size()); diff --git a/src/slic3r/Utils/EmbossStyleManager.hpp b/src/slic3r/Utils/EmbossStyleManager.hpp index 1d902c681..d1cb95d1f 100644 --- a/src/slic3r/Utils/EmbossStyleManager.hpp +++ b/src/slic3r/Utils/EmbossStyleManager.hpp @@ -27,7 +27,6 @@ public: /// /// Release imgui font and style images from GPU - /// Store order and last activ font index /// ~EmbossStyleManager();