Closed learn-more closed 4 months ago
Hello, Nice catch, thanks! Using a reference as a synonym was indeed questionable.
Using an optional might be a solution. However, I think it would be better to remove the legacy synonyms. Not many users are actually using this, and adapting to the new API is straightforward (and I did not make a guarantee of API stability, although I try to keep it stable as much as possible).
If you are willing to push a PR that removes those synonyms, please do :-)
The field
backendType
is mapped toplatformBackendType
with a reference in the structRunnerParams
, but this is problematic as soon as the struct is copied. (It will still point to the old instance).This is visible in debug builds of MSVC in the samples that use the
void Run(const SimpleRunnerParams& simpleRunnerParams)
function (could be indirect), the one I encountered it in ishello_globe
. When starting this in debug, you will hit an assertion that mentionsfailed to factor a runner
, because insideFactorRunner
thebackendType
is0xcccccccc
(The old object is on the stack and happens to be overwritten in a debug build accidentally). (Another thing is thatFactorRunner
should probably not usebackendType
if that is marked as obsolete).Here is a godbolt demonstrating this issue in a simplified form: https://godbolt.org/z/chfs49vxq
My suggestion would be to replace
backendType
with anstd::optional<BackendType> backendType;
, and updateFactorRunner
to useplatformBackendType
ifbackendType
is not set.If you want, I could create a PR for this change?
Additionally, it might make sense to add a ci workflow with the define
HELLOIMGUI_DISABLE_OBSOLETE_BACKEND
set.