Disable ImageExpirationPool during testing (#4363)

* Disable ImageExpirationPool during testing

* Update CHANGELOG.md

---------

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Daniel Sage
2023-02-11 14:20:46 -05:00
committed by GitHub
parent 5179567334
commit cf80ae8434
3 changed files with 29 additions and 8 deletions
+12
View File
@@ -19,6 +19,14 @@
#include <memory>
#include <mutex>
#ifdef CHATTERINO_TEST
// When running tests, the ImageExpirationPool destructor can be called before
// all images are deleted, leading to a use-after-free of its mutex. This
// happens despite the lifetime of the ImageExpirationPool being (apparently)
// static. Therefore, just disable it during testing.
# define DISABLE_IMAGE_EXPIRATION_POOL
#endif
namespace chatterino {
namespace detail {
template <typename Image>
@@ -105,6 +113,8 @@ private:
// forward-declarable function that calls Image::getEmpty() under the hood.
ImagePtr getEmptyImagePtr();
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
class ImageExpirationPool
{
private:
@@ -131,4 +141,6 @@ private:
std::mutex mutex_;
};
#endif
} // namespace chatterino