From a32b76d904e2cd2bc01fc411f564a226b6d0253e Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 28 Sep 2019 13:35:32 +0200 Subject: [PATCH] Fixed error string from userdata return values not persisting long enough. --- src/UserData/UserDataReturnValue.cpp | 2 +- src/UserData/UserDataReturnValue.hpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/UserData/UserDataReturnValue.cpp b/src/UserData/UserDataReturnValue.cpp index 9c0a35d..e49fe88 100644 --- a/src/UserData/UserDataReturnValue.cpp +++ b/src/UserData/UserDataReturnValue.cpp @@ -6,7 +6,7 @@ extern "C"{ } Porygon::UserData::UserDataReturnValue* ErrorValue(const char* message){ - return new Porygon::UserData::UserDataReturnValue(message); + return new Porygon::UserData::UserDataReturnValue(string(message)); } } \ No newline at end of file diff --git a/src/UserData/UserDataReturnValue.hpp b/src/UserData/UserDataReturnValue.hpp index a174531..4dffa03 100644 --- a/src/UserData/UserDataReturnValue.hpp +++ b/src/UserData/UserDataReturnValue.hpp @@ -8,13 +8,17 @@ namespace Porygon::UserData { struct UserDataReturnValue { bool _success; union { - const char *_message; + string _message; const Evaluation::EvalValue *_value; }; public: UserDataReturnValue(Evaluation::EvalValue *value) : _success(true), _value(value) {} UserDataReturnValue(const Evaluation::EvalValue *value) : _success(true), _value(value) {} - UserDataReturnValue(const char *message) : _success(false), _message(message) {} + UserDataReturnValue(string message) : _success(false), _message(message) {} + + ~UserDataReturnValue(){ + + } inline const Evaluation::EvalValue *Evaluate() const{ if (_success) {