summaryrefslogtreecommitdiffstats
path: root/application/pages/LogPage.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-06-11 01:49:13 +0200
committerPetr Mrázek <peterix@gmail.com>2015-06-11 01:50:20 +0200
commit9684d3b0a087b44b39ae8b007c08f82d3ddc6d8f (patch)
tree628d025e770e8c28998be2415743c11d181a396e /application/pages/LogPage.cpp
parent1feb4bb387f1dc559a6d368f77171a6e066a69e6 (diff)
downloadMultiMC-9684d3b0a087b44b39ae8b007c08f82d3ddc6d8f.tar
MultiMC-9684d3b0a087b44b39ae8b007c08f82d3ddc6d8f.tar.gz
MultiMC-9684d3b0a087b44b39ae8b007c08f82d3ddc6d8f.tar.lz
MultiMC-9684d3b0a087b44b39ae8b007c08f82d3ddc6d8f.tar.xz
MultiMC-9684d3b0a087b44b39ae8b007c08f82d3ddc6d8f.zip
GH-1008 implement log window max line count
Defaults to 100k lines
Diffstat (limited to 'application/pages/LogPage.cpp')
-rw-r--r--application/pages/LogPage.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/application/pages/LogPage.cpp b/application/pages/LogPage.cpp
index 7d2013cc..3fade26f 100644
--- a/application/pages/LogPage.cpp
+++ b/application/pages/LogPage.cpp
@@ -8,6 +8,7 @@
#include <QShortcut>
#include "BaseProcess.h"
+#include <settings/Setting.h>
#include "GuiUtil.h"
LogPage::LogPage(BaseProcess *proc, QWidget *parent)
@@ -29,6 +30,18 @@ LogPage::LogPage(BaseProcess *proc, QWidget *parent)
}
defaultFormat->setFont(QFont(fontFamily, fontSize));
+ // ensure we don't eat all the RAM
+ auto lineSetting = MMC->settings()->getSetting("ConsoleMaxLines");
+ int maxLines = lineSetting->get().toInt(&conversionOk);
+ if(!conversionOk)
+ {
+ maxLines = lineSetting->defValue().toInt();
+ qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines;
+ }
+ ui->text->setMaximumBlockCount(maxLines);
+
+ m_stopOnOverflow = MMC->settings()->get("ConsoleOverflowStop").toBool();
+
auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this);
connect(findShortcut, SIGNAL(activated()), SLOT(findActivated()));
auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this);
@@ -126,6 +139,11 @@ void LogPage::findPreviousActivated()
}
}
+void LogPage::setParentContainer(BasePageContainer * container)
+{
+ m_parentContainer = container;
+}
+
void LogPage::write(QString data, MessageLevel::Enum mode)
{
if (!m_write_active)
@@ -135,6 +153,26 @@ void LogPage::write(QString data, MessageLevel::Enum mode)
return;
}
}
+ if(m_stopOnOverflow && m_write_active)
+ {
+ if(mode != MessageLevel::PrePost && mode != MessageLevel::MultiMC)
+ {
+ if(ui->text->blockCount() >= ui->text->maximumBlockCount())
+ {
+ m_write_active = false;
+ data = tr("MultiMC stopped watching the game log because the log length surpassed %1 lines.\n"
+ "You may have to fix your mods because the game is still loggging to files and"
+ " likely wasting harddrive space at an alarming rate!")
+ .arg(ui->text->maximumBlockCount());
+ mode = MessageLevel::Fatal;
+ ui->trackLogCheckbox->setCheckState(Qt::Unchecked);
+ if(!isVisible())
+ {
+ m_parentContainer->selectPage(id());
+ }
+ }
+ }
+ }
// save the cursor so it can be restored.
auto savedCursor = ui->text->cursor();