From d94d6ce0a9587855e71de33416666f8e9145ef64 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Tue, 23 Jan 2024 18:36:55 +0100 Subject: [PATCH] RMG: improve log dialog clear behavior --- Source/RMG/UserInterface/Dialog/LogDialog.cpp | 5 +++++ Source/RMG/UserInterface/Dialog/LogDialog.hpp | 2 ++ Source/RMG/UserInterface/MainWindow.cpp | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/RMG/UserInterface/Dialog/LogDialog.cpp b/Source/RMG/UserInterface/Dialog/LogDialog.cpp index dba121cf..f21a61d5 100644 --- a/Source/RMG/UserInterface/Dialog/LogDialog.cpp +++ b/Source/RMG/UserInterface/Dialog/LogDialog.cpp @@ -29,6 +29,11 @@ LogDialog::~LogDialog(void) { } +int LogDialog::GetLineCount(void) +{ + return this->plainTextEdit->document()->lineCount(); +} + void LogDialog::AddLogLine(CoreDebugMessageType type, QString context, QString line) { QString text; diff --git a/Source/RMG/UserInterface/Dialog/LogDialog.hpp b/Source/RMG/UserInterface/Dialog/LogDialog.hpp index 5eaf31d1..c93d95a8 100644 --- a/Source/RMG/UserInterface/Dialog/LogDialog.hpp +++ b/Source/RMG/UserInterface/Dialog/LogDialog.hpp @@ -31,6 +31,8 @@ class LogDialog : public QDialog, private Ui::LogDialog LogDialog(QWidget* parent = nullptr); ~LogDialog(void); + int GetLineCount(void); + void AddLogLine(CoreDebugMessageType type, QString context, QString line); void Clear(void); }; diff --git a/Source/RMG/UserInterface/MainWindow.cpp b/Source/RMG/UserInterface/MainWindow.cpp index 9e341d54..a6187afd 100644 --- a/Source/RMG/UserInterface/MainWindow.cpp +++ b/Source/RMG/UserInterface/MainWindow.cpp @@ -1836,7 +1836,12 @@ void MainWindow::on_Action_Audio_ToggleVolumeMute(void) void MainWindow::on_Emulation_Started(void) { - this->logDialog.Clear(); + // only clear log dialog when we've gone over the limit + if (this->logDialog.GetLineCount() >= 500000) + { + this->logDialog.Clear(); + } + this->ui_MessageBoxList.clear(); this->ui_DebugCallbackErrors.clear(); }