From d56b35ea91bf40be0af57cd6185917d3d1588b95 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Mon, 19 Sep 2022 13:10:33 -0500 Subject: [PATCH] Made max # of frames an option in preferences, restart to take effect --- canframemodel.cpp | 10 +++++++--- mainsettingsdialog.cpp | 16 ++++++++++++++++ ui/mainsettingsdialog.ui | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 616978b..c4a8309 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "utility.h" CANFrameModel::~CANFrameModel() @@ -45,18 +46,21 @@ int CANFrameModel::columnCount(const QModelIndex &index) const CANFrameModel::CANFrameModel(QObject *parent) : QAbstractTableModel(parent) { - + int maxFramesDefault; if (QSysInfo::WordSize > 32) { qDebug() << "64 bit OS detected. Requesting a large preallocation"; - preallocSize = 10000000; + maxFramesDefault = 10000000; } else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. { qDebug() << "32 bit OS detected. Requesting a much restricted prealloc"; - preallocSize = 2000000; + maxFramesDefault = 2000000; } + QSettings settings; + int preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); + frames.reserve(preallocSize); filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp index 77bf257..2da44ed 100644 --- a/mainsettingsdialog.cpp +++ b/mainsettingsdialog.cpp @@ -90,6 +90,20 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", true).toBool()); ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool()); + int maxFramesDefault; + if (QSysInfo::WordSize > 32) + { + qDebug() << "64 bit OS detected. Requesting a large preallocation"; + maxFramesDefault = 10000000; + } + else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down. + { + qDebug() << "32 bit OS detected. Requesting a much restricted prealloc"; + maxFramesDefault = 2000000; + } + + ui->spinMaximumFrames->setValue(settings.value("Main/MaximumFrames", maxFramesDefault).toInt()); + //just for simplicity they all call the same function and that function updates all settings at once connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbFlowAutoRef, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); @@ -117,6 +131,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : connect(ui->cbHexGraphFlow, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbIgnoreDBCColors, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); + connect(ui->spinMaximumFrames, SIGNAL(valueChanged(int)), this, SLOT(updateSettings())); installEventFilter(this); } @@ -183,6 +198,7 @@ void MainSettingsDialog::updateSettings() settings.setValue("Remote/Pass", encPass); settings.setValue("Main/FilterLabeling", ui->cbFilterLabeling->isChecked()); settings.setValue("Main/IgnoreDBCColors", ui->cbIgnoreDBCColors->isChecked()); + settings.setValue("Main/MaximumFrames", ui->spinMaximumFrames->value()); settings.sync(); emit updatedSettings(); diff --git a/ui/mainsettingsdialog.ui b/ui/mainsettingsdialog.ui index 586e4e0..d119b08 100644 --- a/ui/mainsettingsdialog.ui +++ b/ui/mainsettingsdialog.ui @@ -80,6 +80,39 @@ + + + + 0 + + + 0 + + + + + Maximum Frames to Capture + + + + + + + 100000 + + + 1000000000 + + + 100000 + + + 10000000 + + + + +