Fixed a bug: the edit dialog fields were not cleared if an
[emufront] / src / dialogs / executableeditdialog.cpp
index d23a838..04d1f3e 100644 (file)
@@ -138,6 +138,7 @@ void ExecutableEditDialog::setDataObject(EmuFrontObject *ob)
         qDebug("No executable");
         return;
     }
+    clear();
     if (!ex->getSetup()) {
         qDebug() << "No setup";
         return;
@@ -149,16 +150,25 @@ void ExecutableEditDialog::setDataObject(EmuFrontObject *ob)
     optEdit->setText(ex->getOptions());
 }
 
+void ExecutableEditDialog::clear()
+{
+    nameEdit->clear();
+    execEdit->clear();
+    optEdit->clear();
+    setupComBox->setCurrentIndex(-1);
+}
+
 void ExecutableEditDialog::setSelectedSetup(const Setup *su)
 {
     setupComBox->setSelected(su);
 }
 
+/* Returns a pointer to a Setup object which must be deleted by calling code! */
 Setup* ExecutableEditDialog::getSelectedSetup()
 {
     EmuFrontObject *o = 0;
     try { o = setupComBox->getSelected(); }
-    catch(EmuFrontException &e){ QMessageBox::warning(this, "Exception", e.what()); }
+    catch(EmuFrontException &e){ errorMessage->showMessage(e.what()); }
 
     if (!o) return 0;
     Setup *ex = dynamic_cast<Setup*>(o);