Fix: GDExtension load fails due to Expression used w/o Ref

This commit is contained in:
Serhii Snitsaruk 2024-06-30 14:29:40 +02:00
parent 4d4f0d7886
commit 8dfbd70718
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
2 changed files with 7 additions and 6 deletions

View File

@ -79,7 +79,7 @@ PackedStringArray BTEvaluateExpression::get_configuration_warnings() {
void BTEvaluateExpression::_setup() { void BTEvaluateExpression::_setup() {
parse(); parse();
ERR_FAIL_COND_MSG(is_parsed != Error::OK, "BTEvaluateExpression: Failed to parse expression: " + expression.get_error_text()); ERR_FAIL_COND_MSG(is_parsed != Error::OK, "BTEvaluateExpression: Failed to parse expression: " + expression->get_error_text());
} }
Error BTEvaluateExpression::parse() { Error BTEvaluateExpression::parse() {
@ -93,7 +93,7 @@ Error BTEvaluateExpression::parse() {
processed_input_names_ptr[i + int(input_include_delta)] = input_names[i]; processed_input_names_ptr[i + int(input_include_delta)] = input_names[i];
} }
is_parsed = expression.parse(expression_string, processed_input_names); is_parsed = expression->parse(expression_string, processed_input_names);
return is_parsed; return is_parsed;
} }
@ -109,7 +109,7 @@ BT::Status BTEvaluateExpression::_tick(double p_delta) {
ERR_FAIL_COND_V_MSG(node_param.is_null(), FAILURE, "BTEvaluateExpression: Node parameter is not set."); ERR_FAIL_COND_V_MSG(node_param.is_null(), FAILURE, "BTEvaluateExpression: Node parameter is not set.");
Object *obj = node_param->get_value(get_scene_root(), get_blackboard()); Object *obj = node_param->get_value(get_scene_root(), get_blackboard());
ERR_FAIL_COND_V_MSG(obj == nullptr, FAILURE, "BTEvaluateExpression: Failed to get object: " + node_param->to_string()); ERR_FAIL_COND_V_MSG(obj == nullptr, FAILURE, "BTEvaluateExpression: Failed to get object: " + node_param->to_string());
ERR_FAIL_COND_V_MSG(is_parsed != Error::OK, FAILURE, "BTEvaluateExpression: Failed to parse expression: " + expression.get_error_text()); ERR_FAIL_COND_V_MSG(is_parsed != Error::OK, FAILURE, "BTEvaluateExpression: Failed to parse expression: " + expression->get_error_text());
if (input_include_delta) { if (input_include_delta) {
processed_input_values[0] = p_delta; processed_input_values[0] = p_delta;
@ -119,8 +119,8 @@ BT::Status BTEvaluateExpression::_tick(double p_delta) {
processed_input_values[i + int(input_include_delta)] = bb_variant->get_value(get_scene_root(), get_blackboard()); processed_input_values[i + int(input_include_delta)] = bb_variant->get_value(get_scene_root(), get_blackboard());
} }
Variant result = expression.execute(processed_input_values, obj, false); Variant result = expression->execute(processed_input_values, obj, false);
ERR_FAIL_COND_V_MSG(expression.has_execute_failed(), FAILURE, "BTEvaluateExpression: Failed to execute: " + expression.get_error_text()); ERR_FAIL_COND_V_MSG(expression->has_execute_failed(), FAILURE, "BTEvaluateExpression: Failed to execute: " + expression->get_error_text());
if (result_var != StringName()) { if (result_var != StringName()) {
get_blackboard()->set_var(result_var, result); get_blackboard()->set_var(result_var, result);
@ -156,4 +156,5 @@ void BTEvaluateExpression::_bind_methods() {
} }
BTEvaluateExpression::BTEvaluateExpression() { BTEvaluateExpression::BTEvaluateExpression() {
expression.instantiate();
} }

View File

@ -31,7 +31,7 @@ class BTEvaluateExpression : public BTAction {
TASK_CATEGORY(Utility); TASK_CATEGORY(Utility);
private: private:
Expression expression; Ref<Expression> expression;
Error is_parsed = FAILED; Error is_parsed = FAILED;
Ref<BBNode> node_param; Ref<BBNode> node_param;
String expression_string; String expression_string;