Remove CHATTERINO_TEST definition (#4526)
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
- Dev: Add scripting capabilities with Lua (#4341, #4504)
|
- Dev: Add scripting capabilities with Lua (#4341, #4504)
|
||||||
- Dev: Conan 2.0 is now used instead of Conan 1.0. (#4417)
|
- Dev: Conan 2.0 is now used instead of Conan 1.0. (#4417)
|
||||||
- Dev: Added tests and benchmarks for `LinkParser`. (#4436)
|
- Dev: Added tests and benchmarks for `LinkParser`. (#4436)
|
||||||
|
- Dev: Removed `CHATTERINO_TEST` definitions. (#4526)
|
||||||
|
|
||||||
## 2.4.2
|
## 2.4.2
|
||||||
|
|
||||||
|
|||||||
@@ -169,10 +169,6 @@ endif()
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
if (BUILD_TESTS OR BUILD_BENCHMARKS)
|
|
||||||
add_definitions(-DCHATTERINO_TEST)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Generate resource files
|
# Generate resource files
|
||||||
include(cmake/resources/generate_resources.cmake)
|
include(cmake/resources/generate_resources.cmake)
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
|||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark)
|
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark)
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
|
||||||
CHATTERINO_TEST
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME}
|
set_target_properties(${PROJECT_NAME}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||||
|
|||||||
+9
-15
@@ -8,6 +8,11 @@
|
|||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
#include "debug/AssertInGuiThread.hpp"
|
#include "debug/AssertInGuiThread.hpp"
|
||||||
#include "debug/Benchmark.hpp"
|
#include "debug/Benchmark.hpp"
|
||||||
|
#include "singletons/Emotes.hpp"
|
||||||
|
#include "singletons/helper/GifTimer.hpp"
|
||||||
|
#include "singletons/WindowManager.hpp"
|
||||||
|
#include "util/DebugCount.hpp"
|
||||||
|
#include "util/PostToThread.hpp"
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
@@ -20,13 +25,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
# include "singletons/Emotes.hpp"
|
|
||||||
#endif
|
|
||||||
#include "singletons/helper/GifTimer.hpp"
|
|
||||||
#include "singletons/WindowManager.hpp"
|
|
||||||
#include "util/DebugCount.hpp"
|
|
||||||
#include "util/PostToThread.hpp"
|
|
||||||
|
|
||||||
// Duration between each check of every Image instance
|
// Duration between each check of every Image instance
|
||||||
const auto IMAGE_POOL_CLEANUP_INTERVAL = std::chrono::minutes(1);
|
const auto IMAGE_POOL_CLEANUP_INTERVAL = std::chrono::minutes(1);
|
||||||
@@ -55,12 +53,10 @@ namespace detail {
|
|||||||
{
|
{
|
||||||
DebugCount::increase("animated images");
|
DebugCount::increase("animated images");
|
||||||
|
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
this->gifTimerConnection_ =
|
this->gifTimerConnection_ =
|
||||||
getApp()->emotes->gifTimer.signal.connect([this] {
|
getApp()->emotes->gifTimer.signal.connect([this] {
|
||||||
this->advance();
|
this->advance();
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto totalLength =
|
auto totalLength =
|
||||||
@@ -75,11 +71,9 @@ namespace detail {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
this->durationOffset_ = std::min<int>(
|
this->durationOffset_ = std::min<int>(
|
||||||
int(getApp()->emotes->gifTimer.position() % totalLength),
|
int(getApp()->emotes->gifTimer.position() % totalLength),
|
||||||
60000);
|
60000);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
this->processOffset();
|
this->processOffset();
|
||||||
}
|
}
|
||||||
@@ -228,9 +222,8 @@ namespace detail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
getApp()->windows->forceLayoutChannelViews();
|
getApp()->windows->forceLayoutChannelViews();
|
||||||
#endif
|
|
||||||
loadedEventQueued = false;
|
loadedEventQueued = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,8 +551,9 @@ void Image::expireFrames()
|
|||||||
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
|
#ifndef DISABLE_IMAGE_EXPIRATION_POOL
|
||||||
|
|
||||||
ImageExpirationPool::ImageExpirationPool()
|
ImageExpirationPool::ImageExpirationPool()
|
||||||
|
: freeTimer_(new QTimer)
|
||||||
{
|
{
|
||||||
QObject::connect(&this->freeTimer_, &QTimer::timeout, [this] {
|
QObject::connect(this->freeTimer_, &QTimer::timeout, [this] {
|
||||||
if (isGuiThread())
|
if (isGuiThread())
|
||||||
{
|
{
|
||||||
this->freeOld();
|
this->freeOld();
|
||||||
@@ -572,7 +566,7 @@ ImageExpirationPool::ImageExpirationPool()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this->freeTimer_.start(
|
this->freeTimer_->start(
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
IMAGE_POOL_CLEANUP_INTERVAL));
|
IMAGE_POOL_CLEANUP_INTERVAL));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,6 @@
|
|||||||
#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>
|
||||||
@@ -136,7 +128,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Timer to periodically run freeOld()
|
// Timer to periodically run freeOld()
|
||||||
QTimer freeTimer_;
|
QTimer *freeTimer_;
|
||||||
std::map<Image *, std::weak_ptr<Image>> allImages_;
|
std::map<Image *, std::weak_ptr<Image>> allImages_;
|
||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ const ImagePtr &ImageSet::getImage3() const
|
|||||||
|
|
||||||
const std::shared_ptr<Image> &getImagePriv(const ImageSet &set, float scale)
|
const std::shared_ptr<Image> &getImagePriv(const ImageSet &set, float scale)
|
||||||
{
|
{
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
scale *= getSettings()->emoteScale;
|
scale *= getSettings()->emoteScale;
|
||||||
#endif
|
|
||||||
|
|
||||||
int quality = 1;
|
int quality = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -216,11 +216,7 @@ void Emojis::sortEmojis()
|
|||||||
|
|
||||||
void Emojis::loadEmojiSet()
|
void Emojis::loadEmojiSet()
|
||||||
{
|
{
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
getSettings()->emojiSet.connect([this](const auto &emojiSet) {
|
getSettings()->emojiSet.connect([this](const auto &emojiSet) {
|
||||||
#else
|
|
||||||
const QString emojiSet = "twitter";
|
|
||||||
#endif
|
|
||||||
this->emojis.each([=](const auto &name,
|
this->emojis.each([=](const auto &name,
|
||||||
std::shared_ptr<EmojiData> &emoji) {
|
std::shared_ptr<EmojiData> &emoji) {
|
||||||
QString emojiSetToUse = emojiSet;
|
QString emojiSetToUse = emojiSet;
|
||||||
@@ -265,9 +261,7 @@ void Emojis::loadEmojiSet()
|
|||||||
EmoteName{emoji->value}, ImageSet{Image::fromUrl({url}, 0.35)},
|
EmoteName{emoji->value}, ImageSet{Image::fromUrl({url}, 0.35)},
|
||||||
Tooltip{":" + emoji->shortCodes[0] + ":<br/>Emoji"}, Url{}});
|
Tooltip{":" + emoji->shortCodes[0] + ":<br/>Emoji"}, Url{}});
|
||||||
});
|
});
|
||||||
#ifndef CHATTERINO_TEST
|
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<boost::variant<EmotePtr, QString>> Emojis::parse(
|
std::vector<boost::variant<EmotePtr, QString>> Emojis::parse(
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
|||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE gtest gmock)
|
target_link_libraries(${PROJECT_NAME} PRIVATE gtest gmock)
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
|
||||||
CHATTERINO_TEST
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME}
|
set_target_properties(${PROJECT_NAME}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||||
|
|||||||
Reference in New Issue
Block a user