From 82c6e4b9298375007d7e35ba4d558c592dc7057a Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 7 May 2021 15:01:14 +0900 Subject: [PATCH] Example: Fix memory leak --- example/animation_mixing.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/example/animation_mixing.cpp b/example/animation_mixing.cpp index 093b0e3..29aaaaa 100644 --- a/example/animation_mixing.cpp +++ b/example/animation_mixing.cpp @@ -91,14 +91,21 @@ static void loadRiveFile(const char* filename) Eina_Bool animationLoop(void *data) { + if (!artboard) return ECORE_CALLBACK_RENEW; + for (int i = 0; i < 4; i ++) + { + if (!animationInstance[i]) + { + return ECORE_CALLBACK_RENEW; + } + } + canvas->clear(); double currentTime = ecore_time_get(); float elapsed = currentTime - lastTime; lastTime = currentTime; - if (!artboard || !animationInstance) return ECORE_CALLBACK_RENEW; - for (int i = 0; i < 4; i ++) { if (enableAnimation[i]) @@ -139,7 +146,14 @@ static void runExample(uint32_t* buffer) static void cleanExample() { - delete animationInstance; + for (int i = 0; i < 4; i ++) + { + if (animationInstance[i]) + { + delete animationInstance[i]; + animationInstance[i] = nullptr; + } + } } static void animationChangedCb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) -- 2.7.4