fix: assert for GUI thread in getters instead of get(I)App (#5102)

This commit is contained in:
nerix 2024-01-18 20:50:57 +01:00 committed by GitHub
parent 6fed9dc42a
commit 4f2ca3b174
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 5 deletions

View file

@ -119,7 +119,7 @@
- Dev: Channels without any animated elements on screen will skip updates from the GIF timer. (#5042, #5043, #5045)
- Dev: Autogenerate docs/plugin-meta.lua. (#5055)
- Dev: Refactor `NetworkPrivate`. (#5063)
- Dev: Refactor `Paths` & `Updates`, focusing on reducing their singletoniability. (#5092)
- Dev: Refactor `Paths` & `Updates`, focusing on reducing their singletoniability. (#5092, #5102)
- Dev: Removed duplicate scale in settings dialog. (#5069)
- Dev: Fix `NotebookTab` emitting updates for every message. (#5068)
- Dev: Added benchmark for parsing and building recent messages. (#5071)

View file

@ -305,26 +305,35 @@ int Application::run(QApplication &qtApp)
IEmotes *Application::getEmotes()
{
assertInGuiThread();
return this->emotes;
}
IUserDataController *Application::getUserData()
{
assertInGuiThread();
return this->userData;
}
ISoundController *Application::getSound()
{
assertInGuiThread();
return this->sound;
}
ITwitchLiveController *Application::getTwitchLiveController()
{
assertInGuiThread();
return this->twitchLiveController;
}
TwitchBadges *Application::getTwitchBadges()
{
assertInGuiThread();
assert(this->twitchBadges);
return this->twitchBadges.get();
@ -332,16 +341,22 @@ TwitchBadges *Application::getTwitchBadges()
ITwitchIrcServer *Application::getTwitch()
{
assertInGuiThread();
return this->twitch;
}
PubSub *Application::getTwitchPubSub()
{
assertInGuiThread();
return this->twitchPubSub.get();
}
Logging *Application::getChatLogger()
{
assertInGuiThread();
return this->logging.get();
}
@ -884,8 +899,6 @@ Application *getApp()
{
assert(Application::instance != nullptr);
assertInGuiThread();
return Application::instance;
}
@ -893,8 +906,6 @@ IApplication *getIApp()
{
assert(IApplication::instance != nullptr);
assertInGuiThread();
return IApplication::instance;
}

View file

@ -1,12 +1,14 @@
#pragma once
#include "common/Singleton.hpp"
#include "debug/AssertInGuiThread.hpp"
#include "singletons/NativeMessaging.hpp"
#include <pajlada/signals.hpp>
#include <pajlada/signals/signal.hpp>
#include <QApplication>
#include <cassert>
#include <memory>
namespace chatterino {
@ -161,43 +163,63 @@ public:
}
Theme *getThemes() override
{
assertInGuiThread();
return this->themes;
}
Fonts *getFonts() override
{
assertInGuiThread();
return this->fonts;
}
IEmotes *getEmotes() override;
AccountController *getAccounts() override
{
assertInGuiThread();
return this->accounts;
}
HotkeyController *getHotkeys() override
{
assertInGuiThread();
return this->hotkeys;
}
WindowManager *getWindows() override
{
assertInGuiThread();
return this->windows;
}
Toasts *getToasts() override
{
assertInGuiThread();
return this->toasts;
}
CrashHandler *getCrashHandler() override
{
assertInGuiThread();
return this->crashHandler;
}
CommandController *getCommands() override
{
assertInGuiThread();
return this->commands;
}
NotificationController *getNotifications() override
{
assertInGuiThread();
return this->notifications;
}
HighlightController *getHighlights() override
{
assertInGuiThread();
return this->highlights;
}
ITwitchIrcServer *getTwitch() override;
@ -205,14 +227,20 @@ public:
Logging *getChatLogger() override;
ChatterinoBadges *getChatterinoBadges() override
{
assertInGuiThread();
return this->chatterinoBadges;
}
FfzBadges *getFfzBadges() override
{
assertInGuiThread();
return this->ffzBadges;
}
SeventvBadges *getSeventvBadges() override
{
assertInGuiThread();
return this->seventvBadges;
}
IUserDataController *getUserData() override;
@ -221,14 +249,20 @@ public:
TwitchBadges *getTwitchBadges() override;
ImageUploader *getImageUploader() override
{
assertInGuiThread();
return this->imageUploader;
}
SeventvAPI *getSeventvAPI() override
{
assertInGuiThread();
return this->seventvAPI;
}
Updates &getUpdates() override
{
assertInGuiThread();
return this->updates;
}