diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/object.cpp | 9 | ||||
| -rw-r--r-- | core/project_settings.cpp | 5 | ||||
| -rw-r--r-- | core/ustring.cpp | 20 | ||||
| -rw-r--r-- | core/ustring.h | 2 | ||||
| -rw-r--r-- | core/variant_parser.cpp | 3 |
5 files changed, 29 insertions, 10 deletions
diff --git a/core/object.cpp b/core/object.cpp index ed3ae4f25d..b643aecdd8 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1215,7 +1215,9 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int MessageQueue::get_singleton()->push_call(target->get_instance_id(), c.method, args, argc, true); } else { Variant::CallError ce; + s->lock++; target->call(c.method, args, argc, ce); + s->lock--; if (ce.error != Variant::CallError::CALL_OK) { #ifdef DEBUG_ENABLED @@ -1517,7 +1519,7 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const Signal *s = signal_map.getptr(p_signal); ERR_FAIL_COND_MSG(!s, "Nonexistent signal: " + p_signal + "."); - ERR_FAIL_COND_MSG(s->lock > 0, "Attempt to disconnect signal '" + p_signal + "' while emitting (locks: " + itos(s->lock) + ")."); + ERR_FAIL_COND_MSG(s->lock > 0, "Attempt to disconnect signal '" + p_signal + "' while in emission callback. Use CONNECT_DEFERRED (to be able to safely disconnect) or CONNECT_ONESHOT (for automatic disconnection) as connection flags."); Signal::Target target(p_to_object->get_instance_id(), p_to_method); @@ -1948,7 +1950,10 @@ Object::~Object() { Signal *s = &signal_map[*S]; - ERR_CONTINUE_MSG(s->lock > 0, "Attempt to delete an object in the middle of a signal emission from it."); + if (s->lock > 0) { + //@todo this may need to actually reach the debugger prioritarily somehow because it may crash before + ERR_PRINTS("Object was freed or unreferenced while signal '" + String(*S) + "' is being emitted from it. Try connecting to the signal using 'CONNECT_DEFERRED' flag, or use queue_free() to free the object (if this object is a Node) to avoid this error and potential crashes."); + } //brute force disconnect for performance int slot_count = s->slot_map.size(); diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 067578e354..52087df548 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -769,10 +769,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin String vstr; VariantWriter::write_to_string(value, vstr); - if (F->get().find(" ") != -1) - file->store_string(F->get().quote() + "=" + vstr + "\n"); - else - file->store_string(F->get() + "=" + vstr + "\n"); + file->store_string(F->get().property_name_encode() + "=" + vstr + "\n"); } } diff --git a/core/ustring.cpp b/core/ustring.cpp index 6a1dc2295f..09a02a09be 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -28,6 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS // to disable build-time warning which suggested to use strcpy_s instead strcpy +#endif + #include "ustring.h" #include "core/color.h" @@ -3792,7 +3796,8 @@ bool String::is_valid_float() const { String String::path_to_file(const String &p_path) const { - String src = this->replace("\\", "/").get_base_dir(); + // Don't get base dir for src, this is expected to be a dir already. + String src = this->replace("\\", "/"); String dst = p_path.replace("\\", "/").get_base_dir(); String rel = src.path_to(dst); if (rel == dst) // failed @@ -4054,6 +4059,19 @@ String String::percent_decode() const { return String::utf8(pe.ptr()); } +String String::property_name_encode() const { + // Escape and quote strings with extended ASCII or further Unicode characters + // as well as '"', '=' or ' ' (32) + const CharType *cstr = c_str(); + for (int i = 0; cstr[i]; i++) { + if (cstr[i] == '=' || cstr[i] == '"' || cstr[i] < 33 || cstr[i] > 126) { + return "\"" + c_escape_multiline() + "\""; + } + } + // Keep as is + return *this; +} + String String::get_basename() const { int pos = find_last("."); diff --git a/core/ustring.h b/core/ustring.h index dfc5044942..c20f659c59 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -338,6 +338,8 @@ public: String percent_encode() const; String percent_decode() const; + String property_name_encode() const; + bool is_valid_identifier() const; bool is_valid_integer() const; bool is_valid_float() const; diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index fe2c981c3c..9a5f9c9ede 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1530,9 +1530,6 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r } else if (c != '=') { what += String::chr(c); } else { - if (p_stream->is_utf8()) { - what.parse_utf8(what.ascii(true).get_data()); - } r_assign = what; Token token; get_token(p_stream, token, line, r_err_str); |