Skip to content

[SofaImGui] Construct the DataWidgetFactory map on first use - #305

Merged
alxbilger merged 1 commit into
sofa-framework:masterfrom
fredroy:fix_msvc_cl_fixes
Oct 29, 2026
Merged

alxbilger merged 1 commit into
sofa-framework:masterfrom
fredroy:fix_msvc_cl_fixes

Conversation

@fredroy

@fredroy fredroy commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

fixing some shenanigans to allow clang-msvc to compile sofaimgui
finding this issue without ai would have been .... complicated 💀

factoryMap was an inline static data member, filled by the dw_* globals of ImGuiDataWidget.cpp during static initialization.
With clang-cl, the initializer of an inline variable is emitted in a separately ordered CRT section, so the dw_* initializers could 
run before the map was constructed, crashing with an access violation when loading SofaImGui.dll ("DLL initialization 
routine failed").

factoryMap was an inline static data member, filled by the dw_* globals
of ImGuiDataWidget.cpp during static initialization. With clang-cl, the
initializer of an inline variable is emitted in a separately ordered CRT
section, so the dw_* initializers could run before the map was
constructed, crashing with an access violation when loading
SofaImGui.dll ("DLL initialization routine failed").

The map is now a function-local static, constructed on first use.
@alxbilger
alxbilger merged commit a3953d6 into sofa-framework:master Oct 29, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants