[FEM] check if solver executables exist
- currently one can enter any path for the solver executables, a check is missing - moreover for Z88 the executable name is error-prone (just happened to me and cost me half an hour to find out what is wrong), therefore check also the correct filename. For Elmer this cannot be done since there are different executables one can choose of (e.g. for multi-threading etc.)
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include "DlgSettingsFemElmerImp.h"
|
||||
#include "ui_DlgSettingsFemElmer.h"
|
||||
@@ -35,6 +38,11 @@ DlgSettingsFemElmerImp::DlgSettingsFemElmerImp(QWidget* parent)
|
||||
, ui(new Ui_DlgSettingsFemElmerImp)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->fc_grid_binary_path, &Gui::PrefFileChooser::fileNameChanged,
|
||||
this, &DlgSettingsFemElmerImp::onfileNameChanged);
|
||||
connect(ui->fc_elmer_binary_path, &Gui::PrefFileChooser::fileNameChanged,
|
||||
this, &DlgSettingsFemElmerImp::onfileNameChanged);
|
||||
}
|
||||
|
||||
DlgSettingsFemElmerImp::~DlgSettingsFemElmerImp()
|
||||
@@ -73,4 +81,14 @@ void DlgSettingsFemElmerImp::changeEvent(QEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsFemElmerImp::onfileNameChanged(QString FileName)
|
||||
{
|
||||
if (!QFileInfo::exists(FileName)) {
|
||||
QMessageBox::critical(this, tr("File does not exist"),
|
||||
tr("The specified executable \n'%1'\n does not exist!\n"
|
||||
"Specify another file please.").arg(FileName));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsFemElmerImp.cpp"
|
||||
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
DlgSettingsFemElmerImp( QWidget* parent = nullptr );
|
||||
~DlgSettingsFemElmerImp();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onfileNameChanged(QString FileName);
|
||||
|
||||
protected:
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
|
||||
@@ -37,6 +40,9 @@ DlgSettingsFemZ88Imp::DlgSettingsFemZ88Imp(QWidget* parent)
|
||||
, ui(new Ui_DlgSettingsFemZ88Imp)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->fc_z88_binary_path, &Gui::PrefFileChooser::fileNameChanged,
|
||||
this, &DlgSettingsFemZ88Imp::onfileNameChanged);
|
||||
}
|
||||
|
||||
DlgSettingsFemZ88Imp::~DlgSettingsFemZ88Imp()
|
||||
@@ -92,4 +98,32 @@ void DlgSettingsFemZ88Imp::changeEvent(QEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsFemZ88Imp::onfileNameChanged(QString FileName)
|
||||
{
|
||||
if (!QFileInfo::exists(FileName)) {
|
||||
QMessageBox::critical(this, tr("File does not exist"),
|
||||
tr("The specified z88r executable \n'%1'\n does not exist!\n"
|
||||
"Specify another file please.")
|
||||
.arg(FileName));
|
||||
return;
|
||||
}
|
||||
|
||||
// since the Z88 folder is full of files like "z88h", "z88o" etc. one can easily make a
|
||||
// mistake and is then lost why the solver fails. Therefore check for the correct filename.
|
||||
auto strName = FileName.toStdString();
|
||||
#if defined(FC_OS_WIN32)
|
||||
if (strName.substr(strName.length() - 8) != "z88r.exe") {
|
||||
QMessageBox::critical(this, tr("Wrong file"),
|
||||
tr("You must specify the path to the z88r.exe!"));
|
||||
return;
|
||||
}
|
||||
#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
if (strName.substr(strName.length() - 4) != "z88r") {
|
||||
QMessageBox::critical(this, tr("Wrong file"),
|
||||
tr("You must specify the path to the z88r!"));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsFemZ88Imp.cpp"
|
||||
|
||||
@@ -40,6 +40,9 @@ public:
|
||||
DlgSettingsFemZ88Imp( QWidget* parent = nullptr );
|
||||
~DlgSettingsFemZ88Imp();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onfileNameChanged(QString FileName);
|
||||
|
||||
protected:
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
|
||||
Reference in New Issue
Block a user