-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Table Persistence optimization is breaking reloads. #7934
Description
Version/Branch of Dear ImGui:
1.91-docking
Back-ends:
SDL
Compiler, OS:
Linux + GCC
Full config/build information:
No response
Details:
I'm using multiple save / restore config calls including both ImGui window layout and table layout in order to store and retrieve "workspaces".
This works beautifully, window positions, etc. are restored and table information as well.
I can switch back and forth between config by loading the ini no problem and windows update responsively.
However, I've noticed that some tables sometimes seem to lose their column information, and I've traced it down to an optimization in imgui_tables.cpp (line 3634 onwards), If I change the code as indicated, my INI is slightly larger, but it all works.
how to reproduce
The issue is when a table is created with a default visibility (let's say hidden),
Then that visibility is not stored in the config when the user persists the state.
If the config is loaded into a new environment it works, but if the user made those columns visible, then loaded the config that had it hidden, then the columns are not hidden since those INI items were not written.
I expected it to work the same way with window positions that are persisted even though they have not been moved from their default initial location.
The window example is sensible, and I can understand why the optimization for table column state was initially added, but I think removing it may be more robust.
I'm assuming very few other people use config to switch workspaces on the fly like this.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
// We skip saving some data in the .ini file when they are unnecessary to restore our state.
// Note that fixed width where initial width was derived from auto-fit will always be saved as InitStretchWeightOrWidth will be 0.0f.
// FIXME-TABLE: We don't have logic to easily compare SortOrder to DefaultSortOrder yet so it's always saved when present.
if (width_or_weight != column->InitStretchWeightOrWidth)
settings->SaveFlags |= ImGuiTableFlags_Resizable;
if (column->DisplayOrder != n)
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
if (column->SortOrder != -1)
settings->SaveFlags |= ImGuiTableFlags_Sortable;
if (column->IsUserEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
settings->SaveFlags |= ImGuiTableFlags_Hideable;should perhaps just be:
settings->SaveFlags |= ImGuiTableFlags_Resizable;
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
settings->SaveFlags |= ImGuiTableFlags_Sortable;
settings->SaveFlags |= ImGuiTableFlags_Hideable;