-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table Persistence optimization is breaking reloads. #7934
Comments
I think perhaps the issue could be tackled at the loading stage rather than the saving stage. I tried to build a repro and noticed it only seems to happens for the Do you get it for other states? if (ImGui::Shortcut(ImGuiKey_F1, ImGuiInputFlags_RouteGlobal))
ImGui::LoadIniSettingsFromDisk("imgui_1.ini");
if (ImGui::Shortcut(ImGuiKey_F2, ImGuiInputFlags_RouteGlobal))
ImGui::LoadIniSettingsFromDisk("imgui_2.ini"); imgui_1.ini
imgui_2.ini
|
… correctly overridden when hot-reloading .ini state. (#7934)
I've pushed a fix 4dc9df6 for what I could notice with not reloading Visible/Hidden state correctly, but would like to now if you have other issues. Keeping this open because I'd like to allow write some more tests for this. |
The code between master and docking looks too dissimilar for me to apply this patch easily. But as of docking v1.91.9 WIP, when saving a config containing unmodified settings that match the default, then modifying setting, then restoring the original saved setting, does not restore:
|
I’ll experiment further with this tomorrow. My test above as shown in the recording seems to work (apart from Hidden state as that’s before my first fix), so there must be something else at play. |
I'm not sure if this may be a docking vs. master difference; but reading the code I don't see how to make this work except for writing out all values (including when default). At the time the config is loaded, the code may have changed the defaults - thus loading config where those values are missing it would be impossible to restore the visual state at the time of the originally save. This would be consistent behavior with operations like window position (first use ever) : window positions are persisted even if they don't deviate from the initial set values. This allows for reloading to show it at the last position even if the code has since changed the value if the first use ever position. |
I believe it may be only because you are not on most recent version. The branches are fairly tightly synchronized, whenever they are the imgui_tables.cpp file is identical, and cherry-picking the commit on latest docking works (apart from a conflict in changelog.txt). Anyhow I'll do a merge as soon as this is solved if it is solved soon.
I didn't expect/intend to handle this specific case: I believe it is rather unlikely that app code would actually change default, and the "minified" .ini output is practical and advantageous in the typical use case. So there are two issues IMHO:
I'd appreciate if we can also solve 1 separately, although I understand that always-enabling (2) would naturally solve (1). And for avoidance of doubt:
This specific issue was solved on Monday. |
Another reason I'd like to dig for (1) is there I think there's something smelly that may be deeper (even if not that harmful). The change in fae362f (Oct 2020) which exists today as Could you clarify if for the table where you are having an issue there is a corresponding |
…sible/Hidden state with ImGuiTableColumnFlags_DefaultHide. ocornut/imgui#7934
…ow overwriting/hot-reloading settings. (#7934)
I have pushed another series of fixes which may I have affected you (and merged it all into docking). This doesn't cater for the possibility that defaults (e.g. ImGuiTableColumnFlags_DefaultHide) may be altered between the time the .ini were stored, but I imagine this would be less likely a problem. If the first wave of issues are confirmed fixed we can advise on the rest. |
I've tried your commits in our codebase, and it looks like the column visibility persistence is working, but the column size of columns that were not modified breaks on restore. I did a simple save of settings with a column that had a default fixed width, and immediately restored it. What it seems to do is change the column to best fit or something. If I modify a column width then that still works (as it had before). My column (at index 3 as an example) is created with the following lines:
And the ini when saved without any changes contains only:
If I quit and restart the app, then it works, just if I reload the saved config all my unmodified columns seems to revert to "best fit". Also, when I resize only column 0 and resave, it changes to:
This (obviously) then works subsequently whatever I do since all the values are explicit. |
This is working for me now, I've tried to test all the permutations I could think of. |
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:
should perhaps just be:
The text was updated successfully, but these errors were encountered: