Files
cocos4/native/cocos/editor-support/dragonbones/model/DragonBonesData.cpp
T
James Chen ab733d5644 [v3.6.0] Fix some potential memory issues (#12045)
* Fix deleting IntrusivePtr _pipeline object in Rot.cpp.

* Remove unused code.

* Avoid nullptr dereference in SceneCulling.cpp

* Fix memory leaks for some objective-c code.

* [dragonbones] Avoid extra memory allocation and copy in CCFactory.cpp

* [dragonbones] DragonBonesData::binary needed to be 'freed' rather than 'delete'd.

* [dragonbones] Fix using delete to release memory allocated by 'new[]' in SlotColorTimelineState.

* Remove variable srcOffset & dstOffset in Mesh::merge
2022-07-18 16:39:26 +08:00

51 lines
1.1 KiB
C++

#include "DragonBonesData.h"
#include "UserData.h"
#include "ArmatureData.h"
DRAGONBONES_NAMESPACE_BEGIN
void DragonBonesData::_onClear() {
for (const auto& pair : armatures) {
pair.second->returnToPool();
}
if (binary != nullptr) {
free(const_cast<char*>(binary));
binary = nullptr;
}
if (userData != nullptr) {
userData->returnToPool();
userData = nullptr;
}
autoSearch = false;
frameRate = 0;
version = "";
name = "";
frameIndices.clear();
cachedFrames.clear();
armatureNames.clear();
armatures.clear();
intArray = nullptr;
floatArray = nullptr;
frameIntArray = nullptr;
frameFloatArray = nullptr;
frameArray = nullptr;
timelineArray = nullptr;
}
void DragonBonesData::addArmature(ArmatureData* value) {
if (armatures.find(value->name) != armatures.end()) {
DRAGONBONES_ASSERT(false, "Same armature: " + value->name);
return;
}
value->parent = this;
armatures[value->name] = value;
armatureNames.push_back(value->name);
}
DRAGONBONES_NAMESPACE_END