You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Merge pull request #78987 from RandomShaper/err_bad_deferred_target
Let user know about dead instances in deferred calls
This commit is contained in:
@@ -35,6 +35,10 @@
|
|||||||
#include "core/object/class_db.h"
|
#include "core/object/class_db.h"
|
||||||
#include "core/object/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
#include "core/config/engine.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEV_ENABLED
|
#ifdef DEV_ENABLED
|
||||||
// Includes sanity checks to ensure that a queue set as a thread singleton override
|
// Includes sanity checks to ensure that a queue set as a thread singleton override
|
||||||
// is only ever called from the thread it was set for.
|
// is only ever called from the thread it was set for.
|
||||||
@@ -316,25 +320,34 @@ Error CallQueue::flush() {
|
|||||||
Object *target = message->callable.get_object();
|
Object *target = message->callable.get_object();
|
||||||
|
|
||||||
UNLOCK_MUTEX;
|
UNLOCK_MUTEX;
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
switch (message->type & FLAG_MASK) {
|
if (!message->callable.is_valid()) {
|
||||||
case TYPE_CALL: {
|
// The editor would cause many of these.
|
||||||
if (target || (message->type & FLAG_NULL_IS_OK)) {
|
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||||
Variant *args = (Variant *)(message + 1);
|
ERR_PRINT("Trying to execute a deferred call/notification/set on a previously freed instance. Consider using queue_free() instead of free().");
|
||||||
_call_function(message->callable, args, message->args, message->type & FLAG_SHOW_ERROR);
|
}
|
||||||
}
|
} else
|
||||||
} break;
|
#endif
|
||||||
case TYPE_NOTIFICATION: {
|
{
|
||||||
if (target) {
|
switch (message->type & FLAG_MASK) {
|
||||||
target->notification(message->notification);
|
case TYPE_CALL: {
|
||||||
}
|
if (target || (message->type & FLAG_NULL_IS_OK)) {
|
||||||
} break;
|
Variant *args = (Variant *)(message + 1);
|
||||||
case TYPE_SET: {
|
_call_function(message->callable, args, message->args, message->type & FLAG_SHOW_ERROR);
|
||||||
if (target) {
|
}
|
||||||
Variant *arg = (Variant *)(message + 1);
|
} break;
|
||||||
target->set(message->callable.get_method(), *arg);
|
case TYPE_NOTIFICATION: {
|
||||||
}
|
if (target) {
|
||||||
} break;
|
target->notification(message->notification);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case TYPE_SET: {
|
||||||
|
if (target) {
|
||||||
|
Variant *arg = (Variant *)(message + 1);
|
||||||
|
target->set(message->callable.get_method(), *arg);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
|
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
|
||||||
|
|||||||
Reference in New Issue
Block a user