diff --git a/frontend/OBSApp.cpp b/frontend/OBSApp.cpp index 2fc0488a6..5d8162bf8 100644 --- a/frontend/OBSApp.cpp +++ b/frontend/OBSApp.cpp @@ -74,8 +74,6 @@ extern bool opt_disable_missing_files_check; extern string opt_starting_collection; extern string opt_starting_profile; -extern QPointer obsLogViewer; - #ifndef _WIN32 int OBSApp::sigintFd[2]; #endif @@ -1757,3 +1755,8 @@ void OBSApp::applicationShutdown() noexcept libobs_initialized = false; } } + +void OBSApp::addLogLine(int logLevel, const QString &message) +{ + emit logLineAdded(logLevel, message); +} diff --git a/frontend/OBSApp.hpp b/frontend/OBSApp.hpp index 94e82bb4a..4686f0e32 100644 --- a/frontend/OBSApp.hpp +++ b/frontend/OBSApp.hpp @@ -119,6 +119,7 @@ private slots: #endif private slots: + void addLogLine(int logLevel, const QString &message); void themeFileChanged(const QString &); void applicationShutdown() noexcept; @@ -212,6 +213,7 @@ public slots: void ProcessSigInt(); signals: + void logLineAdded(int logLevel, const QString &message); void StyleChanged(); void logUploadFinished(OBS::LogFileType, const QString &fileUrl); diff --git a/frontend/dialogs/OBSLogViewer.cpp b/frontend/dialogs/OBSLogViewer.cpp index 592111c59..71f16e5cb 100644 --- a/frontend/dialogs/OBSLogViewer.cpp +++ b/frontend/dialogs/OBSLogViewer.cpp @@ -29,6 +29,8 @@ OBSLogViewer::OBSLogViewer(QWidget *parent) : QDialog(parent), ui(new Ui::OBSLog } InitLog(); + + connect(App(), &OBSApp::logLineAdded, this, &OBSLogViewer::AddLine); } OBSLogViewer::~OBSLogViewer() @@ -41,8 +43,6 @@ void OBSLogViewer::on_showStartup_clicked(bool checked) config_set_bool(App()->GetUserConfig(), "LogViewer", "ShowLogStartup", checked); } -extern QPointer obsLogViewer; - void OBSLogViewer::InitLog() { char logDir[512]; @@ -74,8 +74,6 @@ void OBSLogViewer::InitLog() } QScrollBar *scroll = ui->textArea->verticalScrollBar(); scroll->setValue(scroll->maximum()); - - obsLogViewer = this; } void OBSLogViewer::AddLine(int type, const QString &str) diff --git a/frontend/obs-main.cpp b/frontend/obs-main.cpp index 5b5c3e7ca..ce5553a39 100644 --- a/frontend/obs-main.cpp +++ b/frontend/obs-main.cpp @@ -16,7 +16,6 @@ ******************************************************************************/ #include -#include #ifdef __APPLE__ #include #endif @@ -33,7 +32,9 @@ #include #endif +#include #include +#include #include #include @@ -80,8 +81,6 @@ bool restart = false; bool restart_safe = false; static QStringList arguments; -QPointer obsLogViewer; - string CurrentTimeString() { using namespace std::chrono; @@ -115,9 +114,8 @@ static void LogString(fstream &logFile, const char *timeString, char *str, int l logFile << msg << endl; logfile_mutex.unlock(); - if (!!obsLogViewer) - QMetaObject::invokeMethod(obsLogViewer.data(), "AddLine", Qt::QueuedConnection, Q_ARG(int, log_level), - Q_ARG(QString, QString(msg.c_str()))); + QMetaObject::invokeMethod(App(), "addLogLine", Qt::QueuedConnection, Q_ARG(int, log_level), + Q_ARG(QString, QString(msg.c_str()))); } static inline void LogStringChunk(fstream &logFile, char *str, int log_level)