Fix imbuf users leak in MovieClip tiles node
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 22 May 2012 09:15:05 +0000 (09:15 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 22 May 2012 09:15:05 +0000 (09:15 +0000)
Leak was caused by not calling IMB_freeImBuf for result of BKE_movieclip_get_ibuf

source/blender/compositor/nodes/COM_MovieClipNode.cpp
source/blender/compositor/operations/COM_MovieClipOperation.cpp

index 0bddd3280079420f05f599033f0cb2a0b4f669ac..75831130936b0dbb1da07d2303687b62c9681551 100644 (file)
@@ -30,6 +30,7 @@ extern "C" {
        #include "DNA_movieclip_types.h"
        #include "BKE_movieclip.h"
        #include "BKE_tracking.h"
+       #include "IMB_imbuf.h"
 }
 
 MovieClipNode::MovieClipNode(bNode *editorNode): Node(editorNode)
@@ -118,4 +119,8 @@ void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContex
                angleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
                graph->addOperation(operationSetValue);
        }
+
+       if (ibuf) {
+               IMB_freeImBuf(ibuf);
+       }
 }
index d1dab13a9520371a1c8fbb228ae3dec64718a744..b565e48345c86abe79c8a44f2fd2ae22a6824479 100644 (file)
@@ -61,21 +61,27 @@ void MovieClipOperation::initExecution()
 
 void MovieClipOperation::deinitExecution()
 {
-       this->movieClipBuffer = NULL;
+       if (this->movieClipBuffer) {
+               IMB_freeImBuf(this->movieClipBuffer);
+
+               this->movieClipBuffer = NULL;
+       }
 }
 
 void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
 {
        ImBuf *ibuf;
 
-        resolution[0] = 0;
-        resolution[1] = 0;
+       resolution[0] = 0;
+       resolution[1] = 0;
 
        if (this->movieClip) {
                ibuf = BKE_movieclip_get_ibuf(this->movieClip, this->movieClipUser);
                if (ibuf) {
                        resolution[0] = ibuf->x;
                        resolution[1] = ibuf->y;
+
+                       IMB_freeImBuf(ibuf);
                }
        }
 }