Merge pull request #84942 from TokageItLab/leak-res-track-cache
Fix ValueTrack with Resource is leaking
This commit is contained in:
commit
56a2b143a2
|
@ -445,7 +445,7 @@ bool AnimationMixer::is_active() const {
|
||||||
|
|
||||||
void AnimationMixer::set_root_node(const NodePath &p_path) {
|
void AnimationMixer::set_root_node(const NodePath &p_path) {
|
||||||
root_node = p_path;
|
root_node = p_path;
|
||||||
clear_caches();
|
_clear_caches();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodePath AnimationMixer::get_root_node() const {
|
NodePath AnimationMixer::get_root_node() const {
|
||||||
|
@ -454,7 +454,7 @@ NodePath AnimationMixer::get_root_node() const {
|
||||||
|
|
||||||
void AnimationMixer::set_deterministic(bool p_deterministic) {
|
void AnimationMixer::set_deterministic(bool p_deterministic) {
|
||||||
deterministic = p_deterministic;
|
deterministic = p_deterministic;
|
||||||
clear_caches();
|
_clear_caches();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimationMixer::is_deterministic() const {
|
bool AnimationMixer::is_deterministic() const {
|
||||||
|
|
|
@ -143,6 +143,8 @@ protected:
|
||||||
Object *object = nullptr;
|
Object *object = nullptr;
|
||||||
ObjectID object_id;
|
ObjectID object_id;
|
||||||
real_t total_weight = 0.0;
|
real_t total_weight = 0.0;
|
||||||
|
|
||||||
|
virtual ~TrackCache() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TrackCacheTransform : public TrackCache {
|
struct TrackCacheTransform : public TrackCache {
|
||||||
|
@ -164,6 +166,7 @@ protected:
|
||||||
TrackCacheTransform() {
|
TrackCacheTransform() {
|
||||||
type = Animation::TYPE_POSITION_3D;
|
type = Animation::TYPE_POSITION_3D;
|
||||||
}
|
}
|
||||||
|
~TrackCacheTransform() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RootMotionCache {
|
struct RootMotionCache {
|
||||||
|
@ -178,6 +181,7 @@ protected:
|
||||||
float value = 0;
|
float value = 0;
|
||||||
int shape_index = -1;
|
int shape_index = -1;
|
||||||
TrackCacheBlendShape() { type = Animation::TYPE_BLEND_SHAPE; }
|
TrackCacheBlendShape() { type = Animation::TYPE_BLEND_SHAPE; }
|
||||||
|
~TrackCacheBlendShape() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TrackCacheValue : public TrackCache {
|
struct TrackCacheValue : public TrackCache {
|
||||||
|
@ -187,10 +191,16 @@ protected:
|
||||||
bool is_continuous = false;
|
bool is_continuous = false;
|
||||||
bool is_using_angle = false;
|
bool is_using_angle = false;
|
||||||
TrackCacheValue() { type = Animation::TYPE_VALUE; }
|
TrackCacheValue() { type = Animation::TYPE_VALUE; }
|
||||||
|
~TrackCacheValue() {
|
||||||
|
// Clear ref to avoid leaking.
|
||||||
|
init_value = Variant();
|
||||||
|
value = Variant();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TrackCacheMethod : public TrackCache {
|
struct TrackCacheMethod : public TrackCache {
|
||||||
TrackCacheMethod() { type = Animation::TYPE_METHOD; }
|
TrackCacheMethod() { type = Animation::TYPE_METHOD; }
|
||||||
|
~TrackCacheMethod() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TrackCacheBezier : public TrackCache {
|
struct TrackCacheBezier : public TrackCache {
|
||||||
|
@ -200,6 +210,7 @@ protected:
|
||||||
TrackCacheBezier() {
|
TrackCacheBezier() {
|
||||||
type = Animation::TYPE_BEZIER;
|
type = Animation::TYPE_BEZIER;
|
||||||
}
|
}
|
||||||
|
~TrackCacheBezier() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Audio stream information for each audio stream placed on the track.
|
// Audio stream information for each audio stream placed on the track.
|
||||||
|
@ -228,6 +239,7 @@ protected:
|
||||||
TrackCacheAudio() {
|
TrackCacheAudio() {
|
||||||
type = Animation::TYPE_AUDIO;
|
type = Animation::TYPE_AUDIO;
|
||||||
}
|
}
|
||||||
|
~TrackCacheAudio() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TrackCacheAnimation : public TrackCache {
|
struct TrackCacheAnimation : public TrackCache {
|
||||||
|
@ -236,6 +248,7 @@ protected:
|
||||||
TrackCacheAnimation() {
|
TrackCacheAnimation() {
|
||||||
type = Animation::TYPE_ANIMATION;
|
type = Animation::TYPE_ANIMATION;
|
||||||
}
|
}
|
||||||
|
~TrackCacheAnimation() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
RootMotionCache root_motion_cache;
|
RootMotionCache root_motion_cache;
|
||||||
|
@ -377,6 +390,12 @@ class AnimatedValuesBackup : public RefCounted {
|
||||||
public:
|
public:
|
||||||
void set_data(const HashMap<NodePath, AnimationMixer::TrackCache *> p_data) { data = p_data; };
|
void set_data(const HashMap<NodePath, AnimationMixer::TrackCache *> p_data) { data = p_data; };
|
||||||
HashMap<NodePath, AnimationMixer::TrackCache *> get_data() const { return data; };
|
HashMap<NodePath, AnimationMixer::TrackCache *> get_data() const { return data; };
|
||||||
|
|
||||||
|
~AnimatedValuesBackup() {
|
||||||
|
for (KeyValue<NodePath, AnimationMixer::TrackCache *> &K : data) {
|
||||||
|
memdelete(K.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue