Some comments about heap-objects and cleaning up some heap-objects.
[emufront] / src / dialogs / mediaimagepathdialog.cpp
index 5aaab3a..facdf1a 100644 (file)
@@ -100,9 +100,18 @@ void MediaImagePathDialog::setSelectedSetup(const Setup *sup)
     setupComBox->setSelected(sup);
 }
 
+/* Returns a pointer to Setup object which must be deleted by calling code */
 Setup* MediaImagePathDialog::getSelectedSetup()
 {
-    EmuFrontObject *ob = setupComBox->getSelected();
+    EmuFrontObject *ob = 0;
+
+    try {
+        ob = setupComBox->getSelected();
+    }
+    catch(EmuFrontException &e){
+        errorMessage->showMessage(e.what());
+    }
+
     if (!ob) return 0;
     return dynamic_cast<Setup*>(ob);
 }
@@ -131,10 +140,7 @@ void MediaImagePathDialog::acceptChanges()
 
     Setup *tmp = fpo->getSetup();
 
-    int idSup = sup->getId();
-    int idTmp = tmp->getId();
-
-    if (*sup != *tmp)
+    if (!tmp || *sup != *tmp)
     {
         delete tmp;
         fpo->setSetup(sup);