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:
@@ -47,6 +47,7 @@
|
|||||||
- Dev: Added CMake Install Support on Windows. (#4300)
|
- Dev: Added CMake Install Support on Windows. (#4300)
|
||||||
- Dev: Changed conan generator to [`CMakeDeps`](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html) and [`CMakeToolchain`](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html). See PR for migration notes. (#4335)
|
- Dev: Changed conan generator to [`CMakeDeps`](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html) and [`CMakeToolchain`](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html). See PR for migration notes. (#4335)
|
||||||
- Dev: Refactored 7TV EventAPI implementation. (#4342)
|
- Dev: Refactored 7TV EventAPI implementation. (#4342)
|
||||||
|
- Dev: Disabled ImageExpirationPool in tests. (#4363)
|
||||||
- Dev: Don't rely on undocumented registry keys to find the default browser on Windows. (#4362)
|
- Dev: Don't rely on undocumented registry keys to find the default browser on Windows. (#4362)
|
||||||
- Dev: Use `QEnterEvent` for `QWidget::enterEvent` on Qt 6. (#4365)
|
- Dev: Use `QEnterEvent` for `QWidget::enterEvent` on Qt 6. (#4365)
|
||||||
|
|
||||||
|
|||||||
@@ -272,7 +272,9 @@ namespace detail {
|
|||||||
// IMAGE2
|
// IMAGE2
|
||||||
Image::~Image()
|
Image::~Image()
|
||||||
{
|
{
|
||||||
|
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
|
||||||
ImageExpirationPool::instance().removeImagePtr(this);
|
ImageExpirationPool::instance().removeImagePtr(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (this->empty_ && !this->frames_)
|
if (this->empty_ && !this->frames_)
|
||||||
{
|
{
|
||||||
@@ -425,7 +427,9 @@ void Image::load() const
|
|||||||
Image *this2 = const_cast<Image *>(this);
|
Image *this2 = const_cast<Image *>(this);
|
||||||
this2->shouldLoad_ = false;
|
this2->shouldLoad_ = false;
|
||||||
this2->actuallyLoad();
|
this2->actuallyLoad();
|
||||||
|
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
|
||||||
ImageExpirationPool::instance().addImagePtr(this2->shared_from_this());
|
ImageExpirationPool::instance().addImagePtr(this2->shared_from_this());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,6 +555,8 @@ void Image::expireFrames()
|
|||||||
this->shouldLoad_ = true; // Mark as needing load again
|
this->shouldLoad_ = true; // Mark as needing load again
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
|
||||||
|
|
||||||
ImageExpirationPool::ImageExpirationPool()
|
ImageExpirationPool::ImageExpirationPool()
|
||||||
{
|
{
|
||||||
QObject::connect(&this->freeTimer_, &QTimer::timeout, [this] {
|
QObject::connect(&this->freeTimer_, &QTimer::timeout, [this] {
|
||||||
@@ -643,4 +649,6 @@ void ImageExpirationPool::freeOld()
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -19,6 +19,14 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#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 chatterino {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename Image>
|
template <typename Image>
|
||||||
@@ -105,6 +113,8 @@ private:
|
|||||||
// forward-declarable function that calls Image::getEmpty() under the hood.
|
// forward-declarable function that calls Image::getEmpty() under the hood.
|
||||||
ImagePtr getEmptyImagePtr();
|
ImagePtr getEmptyImagePtr();
|
||||||
|
|
||||||
|
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
|
||||||
|
|
||||||
class ImageExpirationPool
|
class ImageExpirationPool
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -131,4 +141,6 @@ private:
|
|||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
Reference in New Issue
Block a user