mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added debug logs and code to assert that we are in the gui thread
This commit is contained in:
parent
b176dc5295
commit
d078ef5fe0
22 changed files with 81 additions and 13 deletions
|
@ -312,7 +312,8 @@ HEADERS += \
|
|||
src/widgets/attachedwindow.hpp \
|
||||
src/util/tupletablemodel.hpp \
|
||||
src/widgets/settingspages/externaltoolspage.hpp \
|
||||
src/util/removescrollareabackground.hpp
|
||||
src/util/removescrollareabackground.hpp \
|
||||
src/util/assertinguithread.h
|
||||
|
||||
RESOURCES += \
|
||||
resources/resources.qrc
|
||||
|
|
|
@ -69,7 +69,7 @@ void AbstractIrcServer::connect()
|
|||
}
|
||||
|
||||
this->onConnected();
|
||||
this->connected.invoke();
|
||||
// this->connected.invoke();
|
||||
}
|
||||
|
||||
void AbstractIrcServer::disconnect()
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace providers {
|
|||
namespace twitch {
|
||||
|
||||
TwitchAccountManager::TwitchAccountManager()
|
||||
: anonymousUser(new TwitchAccount(ANONYMOUS_USERNAME, "", "", ""))
|
||||
{
|
||||
this->anonymousUser.reset(new TwitchAccount(ANONYMOUS_USERNAME, "", "", ""));
|
||||
}
|
||||
|
||||
std::shared_ptr<TwitchAccount> TwitchAccountManager::getCurrent()
|
||||
|
|
|
@ -21,9 +21,10 @@ TwitchServer::TwitchServer()
|
|||
, mentionsChannel(new Channel("/mentions", Channel::TwitchMentions))
|
||||
, watchingChannel(Channel::getEmpty(), Channel::TwitchWatching)
|
||||
{
|
||||
AccountManager::getInstance().Twitch.userChanged.connect([this]() { //
|
||||
util::postToThread([this] { this->connect(); });
|
||||
});
|
||||
qDebug() << "init TwitchServer";
|
||||
|
||||
AccountManager::getInstance().Twitch.userChanged.connect(
|
||||
[this]() { util::postToThread([this] { this->connect(); }); });
|
||||
}
|
||||
|
||||
TwitchServer &TwitchServer::getInstance()
|
||||
|
@ -36,6 +37,8 @@ void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead,
|
|||
{
|
||||
std::shared_ptr<TwitchAccount> account = AccountManager::getInstance().Twitch.getCurrent();
|
||||
|
||||
qDebug() << "logging in as" << account->getUserName();
|
||||
|
||||
QString username = account->getUserName();
|
||||
// QString oauthClient = account->getOAuthClient();
|
||||
QString oauthToken = account->getOAuthToken();
|
||||
|
|
|
@ -17,6 +17,11 @@ inline QString getEnvString(const char *target)
|
|||
|
||||
} // namespace
|
||||
|
||||
AccountManager::AccountManager()
|
||||
{
|
||||
qDebug() << "init AccountManager";
|
||||
}
|
||||
|
||||
AccountManager &AccountManager::getInstance()
|
||||
{
|
||||
static AccountManager instance;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace singletons {
|
|||
|
||||
class AccountManager
|
||||
{
|
||||
AccountManager() = default;
|
||||
AccountManager();
|
||||
|
||||
public:
|
||||
static AccountManager &getInstance();
|
||||
|
|
|
@ -17,6 +17,11 @@ using namespace chatterino::providers::twitch;
|
|||
namespace chatterino {
|
||||
namespace singletons {
|
||||
|
||||
CommandManager::CommandManager()
|
||||
{
|
||||
qDebug() << "init CommandManager";
|
||||
}
|
||||
|
||||
CommandManager &CommandManager::getInstance()
|
||||
{
|
||||
static CommandManager instance;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace singletons {
|
|||
|
||||
class CommandManager
|
||||
{
|
||||
CommandManager() = default;
|
||||
CommandManager();
|
||||
|
||||
public:
|
||||
static CommandManager &getInstance();
|
||||
|
|
|
@ -79,6 +79,7 @@ void FillInFFZEmoteData(const QJsonObject &urls, const QString &code, const QStr
|
|||
EmoteManager::EmoteManager()
|
||||
: findShortCodesRegex(":([-+\\w]+):")
|
||||
{
|
||||
qDebug() << "init EmoteManager";
|
||||
auto &accountManager = AccountManager::getInstance();
|
||||
|
||||
accountManager.Twitch.userChanged.connect([this] {
|
||||
|
|
|
@ -24,6 +24,8 @@ FontManager::FontManager()
|
|||
, currentFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE)
|
||||
// , currentFont(this->currentFontFamily.getValue().c_str(), currentFontSize.getValue())
|
||||
{
|
||||
qDebug() << "init FontManager";
|
||||
|
||||
this->currentFontFamily.connect([this](const std::string &newValue, auto) {
|
||||
this->incGeneration();
|
||||
// this->currentFont.setFamily(newValue.c_str());
|
||||
|
@ -41,7 +43,6 @@ FontManager::FontManager()
|
|||
FontManager &FontManager::getInstance()
|
||||
{
|
||||
static FontManager instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace singletons {
|
|||
LoggingManager::LoggingManager()
|
||||
: pathManager(PathManager::getInstance())
|
||||
{
|
||||
qDebug() << "init LoggingManager";
|
||||
}
|
||||
|
||||
LoggingManager &LoggingManager::getInstance()
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace singletons {
|
|||
|
||||
NativeMessagingManager::NativeMessagingManager()
|
||||
{
|
||||
qDebug() << "init NativeMessagingManager";
|
||||
}
|
||||
|
||||
NativeMessagingManager &NativeMessagingManager::getInstance()
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
namespace chatterino {
|
||||
namespace singletons {
|
||||
|
||||
PathManager::PathManager()
|
||||
{
|
||||
qDebug() << "init PathManager";
|
||||
}
|
||||
|
||||
PathManager &PathManager::getInstance()
|
||||
{
|
||||
static PathManager instance;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace singletons {
|
|||
|
||||
class PathManager
|
||||
{
|
||||
PathManager() = default;
|
||||
PathManager();
|
||||
|
||||
public:
|
||||
static PathManager &getInstance();
|
||||
|
|
|
@ -172,6 +172,8 @@ bool PubSubClient::Send(const char *payload)
|
|||
|
||||
PubSubManager::PubSubManager()
|
||||
{
|
||||
qDebug() << "init PubSubManager";
|
||||
|
||||
this->moderationActionHandlers["clear"] = [this](const auto &data, const auto &roomID) {
|
||||
ClearChatAction action(data, roomID);
|
||||
|
||||
|
@ -444,7 +446,6 @@ void PubSubManager::AddClient()
|
|||
PubSubManager &PubSubManager::getInstance()
|
||||
{
|
||||
static PubSubManager instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -288,6 +288,8 @@ ResourceManager::ResourceManager()
|
|||
, buttonBan(lli(":/images/button_ban.png", 0.25))
|
||||
, buttonTimeout(lli(":/images/button_timeout.png", 0.25))
|
||||
{
|
||||
qDebug() << "init ResourceManager";
|
||||
|
||||
this->loadDynamicTwitchBadges();
|
||||
|
||||
this->loadChatterinoBadges();
|
||||
|
|
|
@ -20,6 +20,8 @@ SettingManager::SettingManager()
|
|||
: snapshot(nullptr)
|
||||
, _ignoredKeywords(new std::vector<QString>)
|
||||
{
|
||||
qDebug() << "init SettingManager";
|
||||
|
||||
this->wordFlagsListener.addSetting(this->showTimestamps);
|
||||
this->wordFlagsListener.addSetting(this->showBadges);
|
||||
this->wordFlagsListener.addSetting(this->enableBttvEmotes);
|
||||
|
|
|
@ -38,6 +38,8 @@ ThemeManager::ThemeManager()
|
|||
: themeName("/appearance/theme/name", "Dark")
|
||||
, themeHue("/appearance/theme/hue", 0.0)
|
||||
{
|
||||
qDebug() << "init ThemeManager";
|
||||
|
||||
this->update();
|
||||
|
||||
this->themeName.connectSimple([this](auto) { this->update(); });
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace singletons {
|
|||
UpdateManager::UpdateManager()
|
||||
: currentVersion(CHATTERINO_VERSION)
|
||||
{
|
||||
qDebug() << "init UpdateManager";
|
||||
}
|
||||
|
||||
UpdateManager &UpdateManager::getInstance()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "singletons/fontmanager.hpp"
|
||||
#include "singletons/pathmanager.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
#include "util/assertinguithread.h"
|
||||
#include "widgets/accountswitchpopupwidget.hpp"
|
||||
#include "widgets/settingsdialog.hpp"
|
||||
|
||||
|
@ -55,6 +56,7 @@ void WindowManager::showAccountSelectPopup(QPoint point)
|
|||
WindowManager::WindowManager(ThemeManager &_themeManager)
|
||||
: themeManager(_themeManager)
|
||||
{
|
||||
qDebug() << "init WindowManager";
|
||||
_themeManager.repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); });
|
||||
}
|
||||
|
||||
|
@ -84,16 +86,22 @@ void WindowManager::repaintGifEmotes()
|
|||
|
||||
widgets::Window &WindowManager::getMainWindow()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
return *this->mainWindow;
|
||||
}
|
||||
|
||||
widgets::Window &WindowManager::getSelectedWindow()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
return *this->selectedWindow;
|
||||
}
|
||||
|
||||
widgets::Window &WindowManager::createWindow(widgets::Window::WindowType type)
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
auto *window = new widgets::Window(this->themeManager, type);
|
||||
this->windows.push_back(window);
|
||||
window->show();
|
||||
|
@ -121,6 +129,8 @@ int WindowManager::windowCount()
|
|||
|
||||
widgets::Window *WindowManager::windowAt(int index)
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
if (index < 0 || (size_t)index >= this->windows.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -131,6 +141,8 @@ widgets::Window *WindowManager::windowAt(int index)
|
|||
|
||||
void WindowManager::initialize()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
assert(!this->initialized);
|
||||
|
||||
// load file
|
||||
|
@ -217,6 +229,8 @@ void WindowManager::initialize()
|
|||
|
||||
void WindowManager::save()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
QJsonDocument document;
|
||||
|
||||
// "serialize"
|
||||
|
@ -296,6 +310,8 @@ void WindowManager::save()
|
|||
|
||||
void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
switch (channel.getType()) {
|
||||
case Channel::Twitch: {
|
||||
obj.insert("type", "twitch");
|
||||
|
@ -315,6 +331,8 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
|
|||
|
||||
IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
QString type = obj.value("type").toString();
|
||||
if (type == "twitch") {
|
||||
return providers::twitch::TwitchServer::getInstance().getOrAddChannel(
|
||||
|
@ -332,6 +350,8 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
|
|||
|
||||
void WindowManager::closeAll()
|
||||
{
|
||||
util::assertInGuiThread();
|
||||
|
||||
for (widgets::Window *window : windows) {
|
||||
window->close();
|
||||
}
|
||||
|
|
18
src/util/assertinguithread.h
Normal file
18
src/util/assertinguithread.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QThread>
|
||||
#include <cassert>
|
||||
|
||||
namespace chatterino {
|
||||
namespace util {
|
||||
|
||||
void assertInGuiThread()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
assert(QCoreApplication::instance()->thread() == QThread::currentThread());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace chatterino
|
|
@ -16,8 +16,7 @@
|
|||
#include <QShortcut>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <QTableView>
|
||||
#include "util/tupletablemodel.hpp"
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
|
Loading…
Reference in a new issue