BUG: Resolve crash by fixing vtkSMPToolsAPI static initialization order issue
requested to merge jcfr/vtk:fix-vtkSMPToolsAPI-crash-ensuring-proper-static-initialization into master
This commit addresses a crash related to the static initialization order 'fiasco' in vtkSMPToolsAPI. It ensures proper deletion of the vtkSMPToolsAPI singleton once the last translation unit referencing it has been unloaded. This correction ensures that the SMP backend is cleaned up at the appropriate time, particularly in applications like 3D Slicer that make use of other singleton.
To avoid altering the public API of vtkSMPToolsAPI, it introduces the variable
InstanceAsPointer
, allowing instantiation on the heap (dynamically).
For more details, see https://github.com/Slicer/Slicer/issues/7449
Edited by Jean-Christophe Fillion-Robin