diff --git a/app/common/memorypool.h b/app/common/memorypool.h index 7b2105f0b..a6abe7aed 100644 --- a/app/common/memorypool.h +++ b/app/common/memorypool.h @@ -23,10 +23,9 @@ #include #include +#include #include -#include - #include "common/define.h" OLIVE_NAMESPACE_ENTER @@ -39,7 +38,7 @@ public: data_ = nullptr; } - ~MemoryPool() { + virtual ~MemoryPool() { delete [] data_; } @@ -67,6 +66,8 @@ public: } void Destroy() { + // FIXME: Invalidate elements sent out here? + delete [] data_; data_ = nullptr; @@ -127,6 +128,8 @@ public: using ElementPtr = std::shared_ptr; ElementPtr Get() { + QMutexLocker locker(&lock_); + for (int i=0;i(e->data()) - reinterpret_cast(data_); int index = diff / GetElementSize(); @@ -158,6 +162,8 @@ private: QVector available_; + QMutex lock_; + }; OLIVE_NAMESPACE_EXIT