[turbine] Fix applicationData to properly return null

This commit is contained in:
Gary Talent 2024-03-17 20:05:01 -05:00
parent 82f02896c9
commit 205f2a698c

View File

@ -99,12 +99,15 @@ template<typename T>
[[nodiscard]] [[nodiscard]]
T *applicationData(Context &ctx) noexcept { T *applicationData(Context &ctx) noexcept {
auto const raw = applicationDataRaw(ctx); auto const raw = applicationDataRaw(ctx);
if (!raw) [[unlikely]] {
return nullptr;
}
#ifdef OX_BARE_METAL #ifdef OX_BARE_METAL
auto const out = static_cast<Wrap<T>*>(raw); auto const out = static_cast<Wrap<T>*>(raw);
#else #else
auto const out = dynamic_cast<Wrap<T>*>(raw); auto const out = dynamic_cast<Wrap<T>*>(raw);
#endif #endif
oxAssert(out || !raw, "Cast failed - wrong type"); oxAssert(out, "Cast failed - wrong type");
return out->data; return out->data;
} }