From 399acf00c7f5f371944de1a3965db4f4ae1ca1fe Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Sat, 7 Nov 2020 17:12:31 +0700 Subject: [PATCH] Use alloc_c_string() to convert String to char* Using get_data() would sometimes result in the wrong data being written. Fixes #12 --- CHANGELOG.md | 3 +++ addons/godot_xterm/native/src/terminal.cpp | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8917ffe..bb80fe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Positioned background rect at 0,0 so it is no longer offset if a margin is added when Terminal is a child of a Container node. - Removed all pre-compiled binaries using BFG [Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/), thus re-writing git history. +### Fixed +- Fixed #12 where incorrect data would sometimes be written to the terminal when passing a string to the Terminal's `write()` method. + ## [1.0.0] - 2020-10-05 ### Added - Changelog. diff --git a/addons/godot_xterm/native/src/terminal.cpp b/addons/godot_xterm/native/src/terminal.cpp index 58815e0..2981089 100644 --- a/addons/godot_xterm/native/src/terminal.cpp +++ b/addons/godot_xterm/native/src/terminal.cpp @@ -585,9 +585,8 @@ void Terminal::write(Variant data) case Variant::Type::STRING: { String string = data; - CharString utf8 = string.utf8(); - u8 = utf8.get_data(); - len = utf8.length(); + u8 = string.alloc_c_string(); + len = strlen(u8); break; } default: