check for errors of the geturl command and abort with message

This commit is contained in:
Axel Kohlmeyer
2024-08-13 00:15:35 -04:00
parent 17ea8d6381
commit a5fe6543a7

View File

@ -1995,8 +1995,18 @@ void LammpsGui::setup_tutorial(int tutno, const QString &dir, bool purgedir, boo
lammps.command("clear"); lammps.command("clear");
lammps.command(QString("shell cd " + dir).toStdString().c_str()); lammps.command(QString("shell cd " + dir).toStdString().c_str());
// read and process manifest // download and process manifest for selected tutorial
// must check for error after download, e.g. when there is no network.
lammps.command(geturl.arg(tutno).arg(".manifest").toStdString().c_str()); lammps.command(geturl.arg(tutno).arg(".manifest").toStdString().c_str());
if (lammps.has_error()) {
constexpr int BUFLEN = 1024;
char errorbuf[BUFLEN];
lammps.get_last_error_message(errorbuf, BUFLEN);
QMessageBox::critical(this, "LAMMPS-GUI download error", QString(errorbuf));
return;
}
QFile manifest(".manifest"); QFile manifest(".manifest");
QString line, first; QString line, first;
if (manifest.open(QIODevice::ReadOnly)) { if (manifest.open(QIODevice::ReadOnly)) {
@ -2021,7 +2031,7 @@ void LammpsGui::setup_tutorial(int tutno, const QString &dir, bool purgedir, boo
manifest.close(); manifest.close();
manifest.remove(); manifest.remove();
} }
open_file(first); if (!first.isEmpty()) open_file(first);
} }
Tutorial1Wizard::Tutorial1Wizard(QWidget *parent) : QWizard(parent) Tutorial1Wizard::Tutorial1Wizard(QWidget *parent) : QWizard(parent)