1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Docking: fixed crash loading certain form of invalid .ini settings. Amends. (#9070)

This commit is contained in:
ocornut 2025-11-17 15:36:49 +01:00
parent 4fa59df9fa
commit ae1d278f3a

View file

@ -17853,6 +17853,11 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
for (int settings_n = 0; settings_n < dc->NodesSettings.Size; settings_n++)
{
ImGuiDockNodeSettings* settings = &dc->NodesSettings[settings_n];
if (pool.GetByKey(settings->ID) != 0)
{
settings->ID = 0; // Duplicate
continue;
}
ImGuiDockContextPruneNodeData* parent_data = settings->ParentNodeId ? pool.GetByKey(settings->ParentNodeId) : 0;
pool.GetOrAddByKey(settings->ID)->RootId = parent_data ? parent_data->RootId : settings->ID;
if (settings->ParentNodeId)
@ -17889,7 +17894,8 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
ImGuiDockContextPruneNodeData* data = pool.GetByKey(settings->ID);
if (data == NULL || data->CountWindows > 1)
continue;
ImGuiDockContextPruneNodeData* data_root = (data->RootId == settings->ID) ? data : pool.GetByKey(data->RootId);
ImGuiDockContextPruneNodeData* data_root = (settings->ID == data->RootId) ? data : pool.GetByKey(data->RootId);
ImGuiDockContextPruneNodeData* data_parent = settings->ParentNodeId ? pool.GetByKey(settings->ParentNodeId) : NULL;
bool remove = false;
remove |= (data->CountWindows == 1 && settings->ParentNodeId == 0 && data->CountChildNodes == 0 && !(settings->Flags & ImGuiDockNodeFlags_CentralNode)); // Floating root node with only 1 window
@ -17901,6 +17907,12 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
DockSettingsRemoveNodeReferences(&settings->ID, 1);
settings->ID = 0;
}
else if (data_parent && data_parent->CountChildNodes == 1)
{
IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextPruneUnusedSettingsNodes: Merge 0x%08X->0X%08X\n", settings->ID, settings->ParentNodeId);
DockSettingsRenameNodeReferences(settings->ID, settings->ParentNodeId);
settings->ID = 0;
}
}
}