mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-10 09:08:42 +08:00
[godot] Closes #2489, fix reference count of SpineAttachments
The SpineAttachment destructor would dereference the spine::Attachment. However, the set_spine_object() call doesn't increase the reference count. This can lead to the attachment being deallocated too early.
This commit is contained in:
parent
dc577acc8d
commit
5abed8a7f6
@ -30,6 +30,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "SpineCommon.h"
|
||||
#include "spine/Attachment.h"
|
||||
#include <spine/spine.h>
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
@ -46,4 +47,10 @@ public:
|
||||
String get_attachment_name();
|
||||
|
||||
Ref<SpineAttachment> copy();
|
||||
|
||||
void set_spine_object(const SpineSkeletonDataResource *_owner, spine::Attachment *_object) {
|
||||
if (get_spine_object()) get_spine_object()->dereference();
|
||||
_set_spine_object_internal(_owner, _object);
|
||||
if (_object) _object->reference();
|
||||
}
|
||||
};
|
||||
|
||||
@ -145,7 +145,7 @@ class SpineSkeletonDataResource;
|
||||
template<typename OBJECT>
|
||||
class SpineSkeletonDataResourceOwnedObject : public SpineObjectWrapper {
|
||||
public:
|
||||
void set_spine_object(const SpineSkeletonDataResource *_owner, OBJECT *_object) {
|
||||
virtual void set_spine_object(const SpineSkeletonDataResource *_owner, OBJECT *_object) {
|
||||
_set_spine_object_internal(_owner, _object);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user