From 5e3ad282a830f161ada8d0064541bb47252774de Mon Sep 17 00:00:00 2001 From: TellowKrinkle <3315070+TellowKrinkle@users.noreply.github.com> Date: Sat, 11 Jul 2026 23:13:53 -0500 Subject: [PATCH] common: Fix build on ryml < 0.11 --- common/YAML.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/common/YAML.cpp b/common/YAML.cpp index 3687e54512..8751fb96db 100644 --- a/common/YAML.cpp +++ b/common/YAML.cpp @@ -119,10 +119,16 @@ std::optional ParseYAMLFromString(ryml::csubstr yaml, ryml::csubstr #else callbacks.m_user_data = static_cast(&context); callbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location location, void* user_data) { - RapidYAMLContext* context = static_cast(user_data); - - Error::SetString(context->error, std::string(msg, msg_len)); - std::longjmp(context->env, 1); + if (RapidYAMLContext* context = static_cast(user_data)) + { + Error::SetString(context->error, std::string(msg, msg_len)); + std::longjmp(context->env, 1); + } + else + { + std::string description(msg, msg_len); + pxFailRel(description.c_str()); + } }; #endif @@ -145,7 +151,11 @@ std::optional ParseYAMLFromString(ryml::csubstr yaml, ryml::csubstr // Callbacks passed to ryml::Tree are used for value parsing errors later, // so we need to clear the context before it goes out of scope. +#if RYML_VERSION_MAJOR > 0 || RYML_VERSION_MINOR >= 11 callbacks.set_user_data(nullptr); +#else + callbacks.m_user_data = nullptr; +#endif tree.callbacks(callbacks); return tree;