Crash fixes for material and animtree

This commit is contained in:
Juan Linietsky 2018-08-20 16:35:36 -03:00
parent c1bd768ca2
commit 031f763d4f
5 changed files with 23 additions and 8 deletions

View file

@ -1530,6 +1530,10 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
void Object::disconnect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method) {
_disconnect(p_signal, p_to_object, p_to_method);
}
void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, bool p_force) {
ERR_FAIL_NULL(p_to_object);
Signal *s = signal_map.getptr(p_signal);
if (!s) {
@ -1550,9 +1554,11 @@ void Object::disconnect(const StringName &p_signal, Object *p_to_object, const S
Signal::Slot *slot = &s->slot_map[target];
slot->reference_count--; // by default is zero, if it was not referenced it will go below it
if (slot->reference_count >= 0) {
return;
if (!p_force) {
slot->reference_count--; // by default is zero, if it was not referenced it will go below it
if (slot->reference_count >= 0) {
return;
}
}
p_to_object->connections.erase(slot->cE);
@ -1965,13 +1971,13 @@ Object::~Object() {
Connection &c = E->get();
ERR_CONTINUE(c.source != this); //bug?
this->disconnect(c.signal, c.target, c.method);
this->_disconnect(c.signal, c.target, c.method, true);
}
while (connections.size()) {
Connection c = connections.front()->get();
c.source->disconnect(c.signal, c.target, c.method);
c.source->_disconnect(c.signal, c.target, c.method, true);
}
ObjectDB::remove_instance(this);

View file

@ -551,6 +551,8 @@ protected:
friend class ClassDB;
virtual void _validate_property(PropertyInfo &property) const;
void _disconnect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, bool p_force = false);
public: //should be protected, but bug in clang++
static void initialize_class();
_FORCE_INLINE_ static void register_custom_data_to_otdb(){};

View file

@ -151,7 +151,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
List<PropertyInfo> plist;
get_property_list(&plist);
Resource *r = (Resource *)ClassDB::instance(get_class());
Resource *r = Object::cast_to<Resource>(ClassDB::instance(get_class()));
ERR_FAIL_COND_V(!r, Ref<Resource>());
r->local_scene = p_for_scene;
@ -182,7 +182,9 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
r->set(E->get().name, p);
}
return Ref<Resource>(r);
RES res = Ref<Resource>(r);
return res;
}
void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache) {

View file

@ -314,6 +314,11 @@ AnimationNodeOneShot::AnimationNodeOneShot() {
mix = MIX_MODE_BLEND;
sync = false;
active = "active";
prev_active = "prev_active";
time = "time";
remaining = "remaining";
}
////////////////////////////////////////////////

View file

@ -34,7 +34,7 @@
void Material::set_next_pass(const Ref<Material> &p_pass) {
ERR_FAIL_COND(p_pass == this);
ERR_FAIL_COND(p_pass.ptr() == this);
if (next_pass == p_pass)
return;