mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix Object::notification order
Previously the `p_reversed` parameter didn't influence the order in a correct way. Also script overridden _notification functions were not called in the correct order. To fix this some `notification` functions had to add a `p_reversed` parameter. This made it necessary to adjust cpp-bindings. Co-authored-by: David Snopek <dsnopek@gmail.com>
This commit is contained in:
parent
247c3548d8
commit
c4705a590b
14 changed files with 314 additions and 28 deletions
|
@ -1921,14 +1921,23 @@ Variant GDScriptInstance::callp(const StringName &p_method, const Variant **p_ar
|
|||
return Variant();
|
||||
}
|
||||
|
||||
void GDScriptInstance::notification(int p_notification) {
|
||||
void GDScriptInstance::notification(int p_notification, bool p_reversed) {
|
||||
//notification is not virtual, it gets called at ALL levels just like in C.
|
||||
Variant value = p_notification;
|
||||
const Variant *args[1] = { &value };
|
||||
|
||||
List<GDScript *> pl;
|
||||
GDScript *sptr = script.ptr();
|
||||
while (sptr) {
|
||||
HashMap<StringName, GDScriptFunction *>::Iterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
|
||||
if (p_reversed) {
|
||||
pl.push_back(sptr);
|
||||
} else {
|
||||
pl.push_front(sptr);
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
}
|
||||
for (GDScript *sc : pl) {
|
||||
HashMap<StringName, GDScriptFunction *>::Iterator E = sc->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
|
||||
if (E) {
|
||||
Callable::CallError err;
|
||||
E->value->call(this, args, 1, err);
|
||||
|
@ -1936,7 +1945,6 @@ void GDScriptInstance::notification(int p_notification) {
|
|||
//print error about notification call
|
||||
}
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue