@@ -171,57 +171,60 @@ SkeletonData* SpineWasmUtil::querySpineSkeletonDataByUUID(const String& uuid) {
171171}
172172
173173SkeletonData* SpineWasmUtil::createSpineSkeletonDataWithJson (const String& jsonStr, const String& altasStr, const spine::Vector<spine::String>& textureNames, const spine::Vector<spine::String>& textureUUIDs) {
174+ SkeletonData* skeletonData = nullptr ;
174175#if ENABLE_JSON_PARSER
175176 auto * atlas = new Atlas (altasStr.buffer (), altasStr.length (), " " , nullptr , false );
176177 if (!atlas) {
177178 return nullptr ;
178179 }
179- AttachmentLoader* attachmentLoader = new AtlasAttachmentLoaderExtension (atlas);
180- #ifdef CC_SPINE_VERSION_3_8
181- SkeletonJson json (attachmentLoader);
182- #else
183- SkeletonJson json (attachmentLoader, true );
184- #endif
185- json.setScale (1 .0F );
186- SkeletonData* skeletonData = json.readSkeletonData (jsonStr.buffer ());
187- auto & errorMsg = json.getError ();
188- if (!errorMsg.isEmpty ()) {
189- logToConsole (errorMsg.buffer (), LOG_LEVEL_WARN);
190- }
180+ {
181+ AttachmentLoader* attachmentLoader = new AtlasAttachmentLoaderExtension (atlas);
182+ #ifdef CC_SPINE_VERSION_3_8
183+ SkeletonJson json (attachmentLoader);
184+ #else
185+ SkeletonJson json (attachmentLoader, true );
186+ #endif
187+ json.setScale (1 .0F );
188+ skeletonData = json.readSkeletonData (jsonStr.buffer ());
189+ auto & errorMsg = json.getError ();
190+ if (!errorMsg.isEmpty ()) {
191+ logToConsole (errorMsg.buffer (), LOG_LEVEL_WARN);
192+ }
191193
192- saveAttachmentVertices (skeletonData, textureNames, textureUUIDs);
194+ saveAttachmentVertices (skeletonData, textureNames, textureUUIDs);
195+ }
196+ delete atlas;
197+ #endif
193198
194199 return skeletonData;
195- #else
196- return nullptr ;
197- #endif
198200}
199201
200202SkeletonData* SpineWasmUtil::createSpineSkeletonDataWithBinary (uint32_t byteSize, const String& altasStr, const spine::Vector<spine::String>& textureNames, const spine::Vector<spine::String>& textureUUIDs) {
203+ SkeletonData* skeletonData = nullptr ;
201204#if ENABLE_BINARY_PARSER
202205 auto * atlas = new Atlas (altasStr.buffer (), altasStr.length (), " " , nullptr , false );
203206 if (!atlas) {
204207 return nullptr ;
205208 }
206- AttachmentLoader* attachmentLoader = new AtlasAttachmentLoaderExtension (atlas);
207- #ifdef CC_SPINE_VERSION_3_8
208- SkeletonBinary binary (attachmentLoader);
209- #else
210- SkeletonBinary binary (attachmentLoader, true );
211- #endif
212- binary.setScale (1 .0F );
213- SkeletonData* skeletonData = binary.readSkeletonData (s_mem, byteSize);
214- auto & errorMsg = binary.getError ();
215- if (!errorMsg.isEmpty ()) {
216- logToConsole (errorMsg.buffer (), LOG_LEVEL_WARN);
217- }
218-
219- saveAttachmentVertices (skeletonData, textureNames, textureUUIDs);
209+ {
210+ AttachmentLoader* attachmentLoader = new AtlasAttachmentLoaderExtension (atlas);
211+ #ifdef CC_SPINE_VERSION_3_8
212+ SkeletonBinary binary (attachmentLoader);
213+ #else
214+ SkeletonBinary binary (attachmentLoader, true );
215+ #endif
216+ binary.setScale (1 .0F );
217+ skeletonData = binary.readSkeletonData (s_mem, byteSize);
218+ auto & errorMsg = binary.getError ();
219+ if (!errorMsg.isEmpty ()) {
220+ logToConsole (errorMsg.buffer (), LOG_LEVEL_WARN);
221+ }
220222
221- return skeletonData;
222- # else
223- return nullptr ;
223+ saveAttachmentVertices ( skeletonData, textureNames, textureUUIDs) ;
224+ }
225+ delete atlas ;
224226#endif
227+ return skeletonData;
225228}
226229
227230void SpineWasmUtil::registerSpineSkeletonDataWithUUID (SkeletonData* data, const String& uuid) {
0 commit comments