diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/thread_local.cpp | 6 | ||||
-rw-r--r-- | platform/qt/src/thread_local.cpp | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/platform/default/thread_local.cpp b/platform/default/thread_local.cpp index b754a04b7d..6fdb1e6dc1 100644 --- a/platform/default/thread_local.cpp +++ b/platform/default/thread_local.cpp @@ -29,7 +29,11 @@ ThreadLocal<T>::ThreadLocal() : impl(std::make_unique<Impl>()) { template <class T> ThreadLocal<T>::~ThreadLocal() { - delete get(); + // ThreadLocal will not take ownership + // of the pointer it is managing. The pointer + // needs to be explicitly cleared before we + // destroy this object. + assert(!get()); if (pthread_key_delete(impl->key)) { Log::Error(Event::General, "Failed to delete local storage key."); diff --git a/platform/qt/src/thread_local.cpp b/platform/qt/src/thread_local.cpp index e48a9d6e74..e835a680e2 100644 --- a/platform/qt/src/thread_local.cpp +++ b/platform/qt/src/thread_local.cpp @@ -4,6 +4,7 @@ #include <mbgl/map/backend_scope.hpp> #include <array> +#include <cassert> #include <QThreadStorage> @@ -23,7 +24,11 @@ ThreadLocal<T>::ThreadLocal() : impl(std::make_unique<Impl>()) { template <class T> ThreadLocal<T>::~ThreadLocal() { - delete get(); + // ThreadLocal will not take ownership + // of the pointer it is managing. The pointer + // needs to be explicitly cleared before we + // destroy this object. + assert(!get()); } template <class T> |