From a1ba843f3668ed53a25f5eb7866d882552028d53 Mon Sep 17 00:00:00 2001 From: TerraAr <37753757+TerraAr@users.noreply.github.com> Date: Fri, 14 Aug 2020 21:42:10 -0300 Subject: [PATCH 1/3] Created operator. Created String::operator+=(const wchar_t), that was mark as Todo. --- src/core/String.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/String.cpp b/src/core/String.cpp index 7340b6d..65d210f 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -135,7 +135,7 @@ void String::operator+=(const String &s) { } void String::operator+=(const wchar_t c) { - // @Todo + _godot_string = godot::api->godot_string_operator_plus(&_godot_string, &(String(c)._godot_string)); } bool String::operator<(const String &s) const { From 5e656923cfe9469a5f33104503e10ca076ce30b8 Mon Sep 17 00:00:00 2001 From: TerraAr <37753757+TerraAr@users.noreply.github.com> Date: Fri, 14 Aug 2020 23:32:38 -0300 Subject: [PATCH 2/3] Fixed operator Fixed String::operator+=(const wchar_t). The problem was that a temporary variable don't have an address. --- src/core/String.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/String.cpp b/src/core/String.cpp index 65d210f..35da37f 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -135,7 +135,8 @@ void String::operator+=(const String &s) { } void String::operator+=(const wchar_t c) { - _godot_string = godot::api->godot_string_operator_plus(&_godot_string, &(String(c)._godot_string)); + String _to_be_added = c; + _godot_string = godot::api->godot_string_operator_plus(&_godot_string, &_to_be_added._godot_string); } bool String::operator<(const String &s) const { From 7d347edb12645e6a7a09539ac1ba10ae1783f2ac Mon Sep 17 00:00:00 2001 From: TerraAr <37753757+TerraAr@users.noreply.github.com> Date: Sat, 15 Aug 2020 15:10:16 -0300 Subject: [PATCH 3/3] Updated operator I've updated the operator that I had created to use the private constructor of the class. --- src/core/String.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/String.cpp b/src/core/String.cpp index 35da37f..72222b7 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -135,8 +135,8 @@ void String::operator+=(const String &s) { } void String::operator+=(const wchar_t c) { - String _to_be_added = c; - _godot_string = godot::api->godot_string_operator_plus(&_godot_string, &_to_be_added._godot_string); + String _to_be_added = String(c); + *this = String(godot::api->godot_string_operator_plus(&_godot_string, &_to_be_added._godot_string)); } bool String::operator<(const String &s) const {