diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2012-08-13 14:56:36 +0400 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2012-08-13 14:56:36 +0400 |
commit | e28fcec04201fb3be19960a0b91fcb20f8d6c56d (patch) | |
tree | dffeb25323ad214ac86f6b4cb0d126d729643eba /source/blender/compositor/operations/COM_MovieDistortionOperation.cpp | |
parent | 64e0202314531f2435d518f522b8f06e956c2f3d (diff) |
Fix for [#32220] regression - DistortionCache is never freed.
* at max 10 cache items will be available. Items will be removed by
latest usage.
* number of cached items can be adjusted in code
* added deinitialization of compositor when blender exists.
* updated scons and cmake build files
Diffstat (limited to 'source/blender/compositor/operations/COM_MovieDistortionOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_MovieDistortionOperation.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 8150e3eda75..a3e00e9325b 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -31,6 +31,15 @@ extern "C" { vector<DistortionCache *> s_cache; +void deintializeDistortionCache(void) +{ + while (s_cache.size()>0) + { + DistortionCache * cache = s_cache.back(); + s_cache.pop_back(); + delete cache; + } +} MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation() { @@ -52,12 +61,14 @@ void MovieDistortionOperation::initExecution() BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber); BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height); - for (unsigned int i = 0; i < s_cache.size(); i++) { + for (unsigned int i = 0; i < s_cache.size(); i++) + { DistortionCache *c = (DistortionCache *)s_cache[i]; if (c->isCacheFor(this->m_movieClip, this->m_width, this->m_height, calibration_width, calibration_height, this->m_distortion)) { this->m_cache = c; + this->m_cache->updateLastUsage(); return; } } @@ -75,6 +86,21 @@ void MovieDistortionOperation::deinitExecution() { this->m_inputOperation = NULL; this->m_movieClip = NULL; + while (s_cache.size() > COM_DISTORTIONCACHE_MAXSIZE) + { + double minTime = PIL_check_seconds_timer(); + vector<DistortionCache*>::iterator minTimeIterator = s_cache.begin(); + for (vector<DistortionCache*>::iterator it = s_cache.begin(); it < s_cache.end(); it ++) + { + DistortionCache * cache = *it; + if (cache->getTimeLastUsage()<minTime) + { + minTime = cache->getTimeLastUsage(); + minTimeIterator = it; + } + } + s_cache.erase(minTimeIterator); + } } |