Load an instance of a plug-in that uses custom fonts in VST3PluginTestHost
Remove the instance
Add another instance. The custom fonts will no longer display correctly.
D2DFont::terminate () (called from ExitDll ()) resets customFonts but since customFontsOnceFlag is not and cannot be reset, customFonts will never be recreated by subsequent calls to getCustomFonts () unless the plug-in's DLL is removed from memory, which may not always happen.
One work-around is to comment out the body of D2DFont::terminate ()
Update: I was seeing this behaviour due to a long-running thread in my plug-in that was expecting to be torn down in a static destructor. This increased the DLL's reference count thereby preventing unloading. Using a static Steinberg::ModuleTerminator to terminate the thread has resolved the issue, but I still think this use of a static std::once_flag is problematic due to the uncertainty around library unloading.
Steps to reproduce:
D2DFont::terminate ()
(called fromExitDll ()
) resetscustomFonts
but sincecustomFontsOnceFlag
is not and cannot be reset,customFonts
will never be recreated by subsequent calls togetCustomFonts ()
unless the plug-in's DLL is removed from memory, which may not always happen.One work-around is to comment out the body of
D2DFont::terminate ()
Update: I was seeing this behaviour due to a long-running thread in my plug-in that was expecting to be torn down in a static destructor. This increased the DLL's reference count thereby preventing unloading. Using a
static Steinberg::ModuleTerminator
to terminate the thread has resolved the issue, but I still think this use of astatic std::once_flag
is problematic due to the uncertainty around library unloading.