Store configuration on gizmo close not destructor

This commit is contained in:
Filip Sykala - NTB T15p 2022-08-05 12:18:21 +02:00
parent fa773f09d3
commit 64728feec3
3 changed files with 10 additions and 7 deletions

View File

@ -601,7 +601,9 @@ void GLGizmoEmboss::on_set_state()
return; return;
} }
m_volume = nullptr; 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(); remove_notification_not_valid_font();
} else if (GLGizmoBase::m_state == GLGizmoBase::On) { } else if (GLGizmoBase::m_state == GLGizmoBase::On) {
if (!m_gui_cfg.has_value()) initialize(); if (!m_gui_cfg.has_value()) initialize();

View File

@ -25,10 +25,6 @@ EmbossStyleManager::EmbossStyleManager(const ImWchar *language_glyph_range)
EmbossStyleManager::~EmbossStyleManager() { EmbossStyleManager::~EmbossStyleManager() {
clear_imgui_font(); clear_imgui_font();
free_style_images(); free_style_images();
store_styles_to_app_config(false, false);
if (m_app_config != nullptr &&
m_last_style_index != std::numeric_limits<size_t>::max())
EmbossStylesSerializable::store_style_index(*m_app_config, m_last_style_index);
} }
void EmbossStyleManager::init(AppConfig *app_config, const EmbossStyles &default_styles) 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; m_style_cache.stored_wx_font = m_style_cache.wx_font;
} }
} }
if (store_activ_index) 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; EmbossStyles styles;
styles.reserve(m_style_items.size()); styles.reserve(m_style_items.size());

View File

@ -27,7 +27,6 @@ public:
/// <summary> /// <summary>
/// Release imgui font and style images from GPU /// Release imgui font and style images from GPU
/// Store order and last activ font index
/// </summary> /// </summary>
~EmbossStyleManager(); ~EmbossStyleManager();