Tables: fixed a bug tracking topology changes (insert new columns in the middle) when the table is not Reorderable. (#9570, #9108, #9572)

This commit is contained in:
ocornut 2026-10-05 18:00:45 +02:00
parent ed73ef4e84
commit 68bd43b2b4
2 changed files with 9 additions and 0 deletions

View File

@ -76,6 +76,9 @@ Other Changes:
- Tables: - Tables:
- Fixed a bug restoring correct .ini columns order when table use is Sortable - Fixed a bug restoring correct .ini columns order when table use is Sortable
but had no user changes. (regression from 1.92.9). (#9519, #9108) but had no user changes. (regression from 1.92.9). (#9519, #9108)
- Fixed a bug tracking topology changes (insert new columns in the middle)
when the table is not _Reorderable: new columns would be ordered incorrectly.
(#9570, #9108, #9572) [@lailoken]
- InpuText: - InpuText:
- Fixed a crash in some cases when using Home key in a WordWrap+ReadOnly field. (#9561) - Fixed a crash in some cases when using Home key in a WordWrap+ReadOnly field. (#9561)
- Selectable: - Selectable:

View File

@ -4107,6 +4107,12 @@ static int IMGUI_CDECL TableFixDisplayOrderComparer(const void* lhs, const void*
// Fix invalid display order data: compact values (0,1,3 -> 0,1,2); preserve relative order (0,3,1 -> 0,2,1); deduplicate (0,4,1,1 -> 0,3,1,2) // Fix invalid display order data: compact values (0,1,3 -> 0,1,2); preserve relative order (0,3,1 -> 0,2,1); deduplicate (0,4,1,1 -> 0,3,1,2)
void ImGui::TableFixDisplayOrder(ImGuiTable* table) void ImGui::TableFixDisplayOrder(ImGuiTable* table)
{ {
if ((table->Flags & ImGuiTableFlags_Reorderable) == 0)
{
for (int n = 0; n < table->ColumnsCount; n++)
table->DisplayOrderToIndex[n] = table->Columns[n].DisplayOrder = (ImGuiTableColumnIdx)n;
return;
}
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
g.TempBuffer.reserve((int)(sizeof(ImGuiTableFixDisplayOrderColumnData) * table->ColumnsCount)); // FIXME: Maybe wrap those two lines as a helper. g.TempBuffer.reserve((int)(sizeof(ImGuiTableFixDisplayOrderColumnData) * table->ColumnsCount)); // FIXME: Maybe wrap those two lines as a helper.
ImGuiTableFixDisplayOrderColumnData* fdo_columns = (ImGuiTableFixDisplayOrderColumnData*)(void*)g.TempBuffer.Data; ImGuiTableFixDisplayOrderColumnData* fdo_columns = (ImGuiTableFixDisplayOrderColumnData*)(void*)g.TempBuffer.Data;