diff --git a/src/duckstation-qt/logwindow.cpp b/src/duckstation-qt/logwindow.cpp index 3decd0821..64b956162 100644 --- a/src/duckstation-qt/logwindow.cpp +++ b/src/duckstation-qt/logwindow.cpp @@ -29,6 +29,9 @@ LogWindow::LogWindow(bool attach_to_main) LogWindow::~LogWindow() { + if (g_log_window == this) + g_log_window = nullptr; + Log::UnregisterCallback(&LogWindow::logCallback, this); } @@ -39,7 +42,7 @@ void LogWindow::updateSettings() const bool curr_enabled = (g_log_window != nullptr); if (new_enabled == curr_enabled) { - if (g_log_window->m_attached_to_main_window != attach_to_main) + if (g_log_window && g_log_window->m_attached_to_main_window != attach_to_main) { g_log_window->m_attached_to_main_window = attach_to_main; if (attach_to_main) @@ -288,6 +291,12 @@ void LogWindow::logCallback(void* pUserParam, const char* channelName, const cha } } +void LogWindow::closeEvent(QCloseEvent* event) +{ + // TODO: Update config. + QMainWindow::closeEvent(event); +} + void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, const QString& message) { QTextCursor temp_cursor = m_text->textCursor(); diff --git a/src/duckstation-qt/logwindow.h b/src/duckstation-qt/logwindow.h index 45efd7059..71b244abd 100644 --- a/src/duckstation-qt/logwindow.h +++ b/src/duckstation-qt/logwindow.h @@ -5,9 +5,9 @@ #include "common/log.h" -#include #include #include +#include class LogWindow : public QMainWindow { @@ -34,6 +34,9 @@ private: static void logCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message); +protected: + void closeEvent(QCloseEvent* event); + private Q_SLOTS: void onClearTriggered(); void onSaveTriggered();