ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.01k stars 10.28k forks source link

Loading a faulty ini file with invalid docked size #7480

Open Yves-911 opened 7 months ago

Yves-911 commented 7 months ago

Version/Branch of Dear ImGui:

Version 1.89.9, Branch: docking

Back-ends:

custom win32

Compiler, OS:

MSVC2022 + Clang 17.6

Full config/build information:

No response

Details:

Loading an invalid ini file


We stumbled accross an ini file with some docking information like (note the 0 on y for the dock node)

[Docking][Data]
DockNode  ID=0x00000001 Pos=1339,543 Size=438,**0**
DockNode  ID=0x00000002 Pos=1348,625 Size=438,286 Selected=0x2E4EBCAA
DockSpace ID=0x6B28C284 Pos=199,928 Size=1154,818 CentralNode=1 Selected=0xD000C8B6

Which obviously trigs this assert IM_ASSERT(ancestor_node->Size.x > 0.0f && ancestor_node->Size.y > 0.0f); in static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window) when trying to open a window that was docked into that node.

As this is really annoying for our users, I fixed it by setting the 0-sized value with the corresponding size of the window trying to instantiate that dock node. Works well so far. I know that this is mainly due because we are manipulating the nodes in maybe a way that is not recommended with multiple hosted viewports in a Win32 app but my question is more : Is there a proper way to deal with malformed ini files ? Or there will still be Asserts, making the ini file unusable ?

Thanks ! Yves.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
ocornut commented 7 months ago

I'd be willing to add some recovery for that data, but only if I had a repro that created this invalid data in the first place. It's possible that your code manipulating node data is incorrect.

Yves-911 commented 7 months ago

Thanks for your reply ! I don't have the time right now to dive into the root cause which is almost for sure on our side. Whenever I stumble on a 100% repro code, I'll update the thread. I'll keep my local fix for now to unblock our users.