diff --git a/include/MUtils/Lazy.h b/include/MUtils/Lazy.h index 3f6eb10..e5fb12d 100644 --- a/include/MUtils/Lazy.h +++ b/include/MUtils/Lazy.h @@ -69,6 +69,14 @@ namespace MUtils return *m_value; } + ~Lazy(void) + { + if(T *const value = m_value.fetchAndStoreOrdered(NULL)) + { + delete value; + } + } + private: QAtomicPointer m_value; const std::function m_initializer;