Skip to content

Commit

Permalink
Fix rare corruption of ini filename on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Jun 29, 2024
1 parent 2aaef1d commit 9b1a46f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gdext/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,13 @@ void RebuildFontAtlas()
void SetIniFilename(const String& fn)
{
ImGuiIO& io = ImGui::GetIO();
static std::vector<char> iniFilename;
if (fn.length() > 0)
{
std::string globalfn = ProjectSettings::get_singleton()->globalize_path(fn).utf8().get_data();
iniFilename.resize(globalfn.length() + 1);
std::copy(globalfn.begin(), globalfn.end(), iniFilename.begin());
iniFilename.back() = '\0';
io.IniFilename = iniFilename.data();
ctx->iniFilename.resize(globalfn.length() + 1);
std::copy(globalfn.begin(), globalfn.end(), ctx->iniFilename.begin());
ctx->iniFilename.back() = '\0';
io.IniFilename = ctx->iniFilename.data();
}
else
io.IniFilename = nullptr;
Expand Down
1 change: 1 addition & 0 deletions gdext/src/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct Context
Vector2i viewportSize;
ImGuiLayer* layer = nullptr;
bool inProcessFrame = false;
std::vector<char> iniFilename;

Context(std::unique_ptr<Renderer> r);
~Context();
Expand Down

0 comments on commit 9b1a46f

Please sign in to comment.