//
//
// EmuFront is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
//
// EmuFront is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
try {
Setup *su = getSelectedSetup();
if (!su) {
- throw new EmuFrontException(tr("Setup not selected"));
+ throw EmuFrontException(tr("Setup not selected"));
}
QString name = nameEdit->text().trimmed();
if (name.isEmpty()){
- throw new EmuFrontException(tr("Name is not set"));
+ throw EmuFrontException(tr("Name is not set"));
}
QString exec = execEdit->text().trimmed();
if (exec.isEmpty()){
- throw new EmuFrontException(tr("Executable is not set"));
+ throw EmuFrontException(tr("Executable is not set"));
}
QString opts = optEdit->text().trimmed();
if (opts.isEmpty()) {
- throw new EmuFrontException(tr("Options not set"));
+ throw EmuFrontException(tr("Options not set"));
}
+ bool change = false;
Setup *supTmp = ex->getSetup();
- if (supTmp != su) {
+ if (!supTmp || *supTmp != *su) {
delete supTmp;
ex->setSetup(su);
+ change = true;
}
- ex->setName(name);
- ex->setExecutable(exec);
- ex->setOptions(opts);
- emit dataObjectUpdated();
+
+ if (name != ex->getName()) {
+ ex->setName(name);
+ change = true;
+ }
+
+ if (exec != ex->getExecutable()) {
+ ex->setExecutable(exec);
+ change = true;
+ }
+ if (opts != ex->getOptions()) {
+ ex->setOptions(opts);
+ change = true;
+ }
+ if (change) emit dataObjectUpdated();
efObject = 0;
close();
} catch(EmuFrontException x) {
if (!ob) return;
efObject = ob;
Executable *ex = dynamic_cast<Executable*>(ob);
- if (ex->getSetup()) setSelectedSetup(ex->getSetup());
+ if (!ex) {
+ qDebug("No executable");
+ return;
+ }
+ if (!ex->getSetup()) {
+ qDebug() << "No setup";
+ return;
+ }
+ if (ex->getSetup() && ex->getSetup()->getId() >= 0)
+ setSelectedSetup(ex->getSetup());
nameEdit->setText(ex->getName());
execEdit->setText(ex->getExecutable());
optEdit->setText(ex->getOptions());
setupComBox->setSelected(su);
}
-Setup* ExecutableEditDialog::getSelectedSetup() const
+Setup* ExecutableEditDialog::getSelectedSetup()
{
- EmuFrontObject *o = setupComBox->getSelected();
+ EmuFrontObject *o = 0;
+ try { o = setupComBox->getSelected(); }
+ catch(EmuFrontException &e){ QMessageBox::warning(this, "Exception", e.what()); }
+
if (!o) return 0;
Setup *ex = dynamic_cast<Setup*>(o);
return ex;