Docking: Fix a crash that could occur with a malformed ini file (DockNode Parent value pointing to a missing node)

This commit is contained in:
omar 2019-08-01 15:50:05 -07:00
parent 967073ba3d
commit 3aa9aae0be

View File

@ -11426,12 +11426,13 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
} }
// Count reference to dock ids from window settings // Count reference to dock ids from window settings
// We guard against the possibility of an invalid .ini file (RootID may point to a missing node)
for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++) for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++)
if (ImGuiID dock_id = g.SettingsWindows[settings_n].DockId) if (ImGuiID dock_id = g.SettingsWindows[settings_n].DockId)
if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id)) if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id))
{ {
ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID);
data->CountWindows++; data->CountWindows++;
if (ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID))
data_root->CountChildWindows++; data_root->CountChildWindows++;
} }