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: 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: Autogenerate docs/plugin-meta.lua. (#5055)
- Dev: Refactor `NetworkPrivate`. (#5063) - 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: Removed duplicate scale in settings dialog. (#5069)
- Dev: Fix `NotebookTab` emitting updates for every message. (#5068) - Dev: Fix `NotebookTab` emitting updates for every message. (#5068)
- Dev: Added benchmark for parsing and building recent messages. (#5071) - Dev: Added benchmark for parsing and building recent messages. (#5071)

View file

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

View file

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