reset number of threads to 1 when using no accelerator or opt

This commit is contained in:
Axel Kohlmeyer
2023-10-03 16:13:59 -04:00
parent 75050b8920
commit 6a43ca8410
2 changed files with 11 additions and 4 deletions

View File

@ -508,6 +508,8 @@ void LammpsGui::update_variables()
for (const auto &line : doc) {
if (line.isEmpty()) continue;
// first find variable definitions.
// index variables are special since they can be overridden from the command line
auto index = indexvar.match(line);

View File

@ -40,8 +40,8 @@
#include <QSpacerItem>
#include <QSpinBox>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QThread>
#include <QVBoxLayout>
#if defined(_OPENMP)
#include <omp.h>
@ -110,10 +110,15 @@ void Preferences::accept()
}
}
// store number of threads
// store number of threads, reset to 1 for "None" and "Opt" settings
QLineEdit *field = tabWidget->findChild<QLineEdit *>("nthreads");
if (field)
if (field->hasAcceptableInput()) settings->setValue("nthreads", field->text());
if (field) {
int accel = settings->value("accelerator", AcceleratorTab::None).toInt();
if ((accel == AcceleratorTab::None) || (accel == AcceleratorTab::Opt))
settings->setValue("nthreads", 1);
else if (field->hasAcceptableInput())
settings->setValue("nthreads", field->text());
}
// store image width, height, zoom, and rendering settings