* there is a tiny memory leak. I think it happens when you quit blenden
authorJeroen Bakker <j.bakker@atmind.nl>
Tue, 4 Sep 2012 11:08:47 +0000 (11:08 +0000)
committerJeroen Bakker <j.bakker@atmind.nl>
Tue, 4 Sep 2012 11:08:47 +0000 (11:08 +0000)
during a WM_draw. tiny is max 8* size of pointer and it is maintained at
that size. So no worries there.
 * cleanup some code to be certain that deinitialization happens
correctly.

source/blender/compositor/COM_compositor.h
source/blender/compositor/intern/COM_WorkScheduler.cpp
source/blender/compositor/intern/COM_compositor.cpp

index d9cfae8edb9f3a067e03874330e9d633fae8c13a..e6efd77f8b2f8c69febcb971d78c9a5497e8ef21 100644 (file)
@@ -301,9 +301,16 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering);
 
 /**
  * @brief Deinitialize the compositor caches and allocated memory.
+ * Use COM_clearCaches to only free the caches.
  */
 void COM_deinitialize(void);
 
+/**
+ * @brief Clear all compositor caches. (Compositor system will still remain available). 
+ * To deinitialize the compositor use the COM_deinitialize method.
+ */
+void COM_clearCaches(void);
+
 /**
  * @brief Return a list of highlighted bnodes pointers.
  * @return 
index f9af23faea8f7d4c7992045ee3492b7948adbe48..f7ae2945471f467fd79ab95ed7df5fb7719dcf32 100644 (file)
@@ -103,7 +103,13 @@ void **g_highlightedNodesRead;
 
 void COM_startReadHighlights()
 {
-       if (g_highlightedNodesRead) {
+       if (!g_highlightInitialized)
+       {
+               return;
+       }
+       
+       if (g_highlightedNodesRead) 
+       {
                MEM_freeN(g_highlightedNodesRead);
        }
        
@@ -114,6 +120,11 @@ void COM_startReadHighlights()
 
 int COM_isHighlightedbNode(bNode *bnode)
 {
+       if (!g_highlightInitialized)
+       {
+               return false;
+       }
+       
        if (!g_highlightedNodesRead) {
                return false;
        }
@@ -397,13 +408,18 @@ void WorkScheduler::deinitialize()
 
        /* deinitialize highlighting */
        if (g_highlightInitialized) {
-               if (g_highlightedNodes)
+               g_highlightInitialized = false;
+               if (g_highlightedNodes) 
+               {
                        MEM_freeN(g_highlightedNodes);
+                       g_highlightedNodes = NULL;
+               }
 
-               if (g_highlightedNodesRead)
+               if (g_highlightedNodesRead) 
+               {
                        MEM_freeN(g_highlightedNodesRead);
-
-               g_highlightInitialized = false;
+                       g_highlightedNodesRead = NULL;
+               }
        }
 }
 
index daf48d65cafefce3afda4453b98c2a29e706ad23..6369eff30486eb6a0072435937d01fde9bb4c6ad 100644 (file)
@@ -37,6 +37,11 @@ extern "C" {
 static ThreadMutex s_compositorMutex;
 static char is_compositorMutex_init = FALSE;
 
+void intern_freeCompositorCaches() 
+{
+       deintializeDistortionCache();
+}
+
 void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
 {
        /* initialize mutex, TODO this mutex init is actually not thread safe and
@@ -86,14 +91,22 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
        BLI_mutex_unlock(&s_compositorMutex);
 }
 
+void COM_freeCaches() 
+{
+       if (is_compositorMutex_init)
+       {
+               BLI_mutex_lock(&s_compositorMutex);
+               intern_freeCompositorCaches();
+               BLI_mutex_unlock(&s_compositorMutex);
+       }
+}
+
 void COM_deinitialize() 
 {
        if (is_compositorMutex_init) {
                BLI_mutex_lock(&s_compositorMutex);
-
-               deintializeDistortionCache();
+               intern_freeCompositorCaches();
                WorkScheduler::deinitialize();
-
                is_compositorMutex_init = FALSE;
                BLI_mutex_unlock(&s_compositorMutex);
                BLI_mutex_end(&s_compositorMutex);