fix: deadlock and use-after-free in tests (#4981)

* fix: use-after-free in settings

* refactor: put seventv api into a singleton

* chore: add changelog entry

* Add warning for when the 7TV load fails
This commit is contained in:
nerix
2023-11-26 16:54:19 +01:00
committed by GitHub
parent 854032fce9
commit e8673fc52a
12 changed files with 57 additions and 27 deletions
+22 -12
View File
@@ -1,5 +1,7 @@
#pragma once
#include "common/Singleton.hpp"
#include <functional>
class QString;
@@ -9,25 +11,33 @@ namespace chatterino {
class NetworkResult;
class SeventvAPI
class SeventvAPI : public Singleton
{
using ErrorCallback = std::function<void(const NetworkResult &)>;
template <typename... T>
using SuccessCallback = std::function<void(T...)>;
public:
void getUserByTwitchID(const QString &twitchID,
SuccessCallback<const QJsonObject &> &&onSuccess,
ErrorCallback &&onError);
void getEmoteSet(const QString &emoteSet,
SuccessCallback<const QJsonObject &> &&onSuccess,
ErrorCallback &&onError);
SeventvAPI() = default;
~SeventvAPI() override = default;
void updatePresence(const QString &twitchChannelID,
const QString &seventvUserID,
SuccessCallback<> &&onSuccess, ErrorCallback &&onError);
SeventvAPI(const SeventvAPI &) = delete;
SeventvAPI(SeventvAPI &&) = delete;
SeventvAPI &operator=(const SeventvAPI &) = delete;
SeventvAPI &operator=(SeventvAPI &&) = delete;
virtual void getUserByTwitchID(
const QString &twitchID,
SuccessCallback<const QJsonObject &> &&onSuccess,
ErrorCallback &&onError);
virtual void getEmoteSet(const QString &emoteSet,
SuccessCallback<const QJsonObject &> &&onSuccess,
ErrorCallback &&onError);
virtual void updatePresence(const QString &twitchChannelID,
const QString &seventvUserID,
SuccessCallback<> &&onSuccess,
ErrorCallback &&onError);
};
SeventvAPI &getSeventvAPI();
} // namespace chatterino