summaryrefslogtreecommitdiffstats
path: root/core/object/object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/object/object.cpp')
-rw-r--r--core/object/object.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 97a3a405b9..a2330ecd04 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -38,7 +38,7 @@
#include "core/object/script_language.h"
#include "core/os/os.h"
#include "core/string/print_string.h"
-#include "core/string/translation.h"
+#include "core/string/translation_server.h"
#include "core/templates/local_vector.h"
#include "core/variant/typed_array.h"
@@ -207,10 +207,13 @@ void Object::cancel_free() {
_predelete_ok = false;
}
-void Object::_postinitialize() {
- _class_name_ptr = _get_class_namev(); // Set the direct pointer, which is much faster to obtain, but can only happen after postinitialize.
+void Object::_initialize() {
+ _class_name_ptr = _get_class_namev(); // Set the direct pointer, which is much faster to obtain, but can only happen after _initialize.
_initialize_classv();
_class_name_ptr = nullptr; // May have been called from a constructor.
+}
+
+void Object::_postinitialize() {
notification(NOTIFICATION_POSTINITIALIZE);
}
@@ -763,7 +766,7 @@ Variant Object::callp(const StringName &p_method, const Variant **p_args, int p_
}
if (is_ref_counted()) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
- ERR_FAIL_V_MSG(Variant(), "Can't 'free' a reference.");
+ ERR_FAIL_V_MSG(Variant(), "Can't free a RefCounted object.");
}
if (_lock_index.get() > 1) {
@@ -994,7 +997,7 @@ void Object::set_meta(const StringName &p_name, const Variant &p_value) {
if (E) {
E->value = p_value;
} else {
- ERR_FAIL_COND_MSG(!p_name.operator String().is_valid_identifier(), "Invalid metadata identifier: '" + p_name + "'.");
+ ERR_FAIL_COND_MSG(!p_name.operator String().is_valid_ascii_identifier(), "Invalid metadata identifier: '" + p_name + "'.");
Variant *V = &metadata.insert(p_name, p_value)->value;
const String &sname = p_name;
@@ -2097,7 +2100,11 @@ Object::~Object() {
// Disconnect signals that connect to this object.
while (connections.size()) {
Connection c = connections.front()->get();
- bool disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
+ Object *obj = c.callable.get_object();
+ bool disconnected = false;
+ if (likely(obj)) {
+ disconnected = c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
+ }
if (unlikely(!disconnected)) {
// If the disconnect has failed, abandon the connection to avoid getting trapped in an infinite loop here.
connections.pop_front();
@@ -2125,6 +2132,7 @@ bool predelete_handler(Object *p_object) {
}
void postinitialize_handler(Object *p_object) {
+ p_object->_initialize();
p_object->_postinitialize();
}