From b4a59ef4f256fae2f29446aa88a248f2e102173b Mon Sep 17 00:00:00 2001 From: Quentin Quadrat Date: Sat, 6 Jan 2024 19:30:28 +0100 Subject: [PATCH] Fix memory corruption when application is ending --- data/imgui.ini | 8 ++++++++ src/Editor/PetriEditor.cpp | 8 ++++++-- src/Editor/PetriEditor.hpp | 1 - 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/data/imgui.ini b/data/imgui.ini index f6c8b27..343499f 100644 --- a/data/imgui.ini +++ b/data/imgui.ini @@ -108,6 +108,14 @@ Column 0 Sort=0v RefScale=13 Column 0 Sort=0v +[Table][0x9B8096DD,4] +RefScale=13 +Column 0 Sort=0v + +[Table][0x7A58EED9,4] +RefScale=13 +Column 0 Sort=0v + [Docking][Data] DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,19 Size=1024,749 Split=Y DockNode ID=0x00000003 Parent=0x8B93E3BD SizeRef=1024,681 Split=X diff --git a/src/Editor/PetriEditor.cpp b/src/Editor/PetriEditor.cpp index 5218fdf..55df1d4 100644 --- a/src/Editor/PetriEditor.cpp +++ b/src/Editor/PetriEditor.cpp @@ -29,6 +29,10 @@ namespace tpne { +//! \brief path of the file storing dear imgui widgets. Cannot be placed +//! as member variable of Editor class. +static std::string g_ini_filename = "imgui.ini"; + //-------------------------------------------------------------------------- Editor::Editor(size_t const width, size_t const height, std::string const& title) @@ -53,8 +57,8 @@ void Editor::startUp(std::string const& filepath) // Set imgui.ini loading/saving location ImGuiIO &io = ImGui::GetIO(); - m_states.ini_filename = m_path.expand("imgui.ini").c_str(); - io.IniFilename = m_states.ini_filename.c_str(); + g_ini_filename = m_path.expand("imgui.ini").c_str(); + io.IniFilename = g_ini_filename.c_str(); std::cout << "imgui.ini path: " << io.IniFilename << std::endl; // Setup fonts diff --git a/src/Editor/PetriEditor.hpp b/src/Editor/PetriEditor.hpp index f95279d..4366231 100644 --- a/src/Editor/PetriEditor.hpp +++ b/src/Editor/PetriEditor.hpp @@ -120,7 +120,6 @@ class Editor: public Application ImVec2 viewport_center; std::string title; bool request_quitting = false; - std::string ini_filename = "imgui.ini"; }; // ************************************************************************