jvcleave / ofxImGui

Use ImGui in openFrameworks
293 stars 124 forks source link

EXC_BAD_ACCESS when closing app in iOS #74

Closed thinium closed 6 years ago

thinium commented 6 years ago

Hi! For some reason my app is crashing when closing the app on an iPad.

It first crashes in ImGui::Shutdown() inside SaveSettings().

screen shot 2018-04-20 at 12 14 12

Since I don't care about saving settings I comment out SaveSettings() and then it crashes in the following for loop:

for (int i = 0; i < g.Windows.Size; i++)
    {
        g.Windows[i]->~ImGuiWindow(); // <-- crash here
        ImGui::MemFree(g.Windows[i]);
    }
...
ImGuiWindow::~ImGuiWindow()
{
    DrawList->~ImDrawList(); // <-- crash here
    ImGui::MemFree(DrawList);
    DrawList = NULL;
    ImGui::MemFree(Name);
    Name = NULL;
}
screen shot 2018-04-20 at 12 25 21

Shutdown is called automatically before exit callbacks because it's in some kind of "release pool".

screen shot 2018-04-20 at 12 39 13

Do you have any ideas for debugging this? The same program was working fine last year, but I don't know if an update to OF (now 0.10), to my program or to iOS is causing this. ofxImGui has not been changed in my system.

jvcleave commented 6 years ago

I would try

if(DrawList)
{
  DrawList->~ImDrawList();
  ImGui::Memfree(Drawlist);
}
thinium commented 6 years ago

Thanks for the suggestion! It turns out that our imgui object is not explicitly deleted during destruction phase. Now it's working fine :)