Fixed bugs: dialogs remained disabled (signals were not attached to
[emufront] / src / dialogs / mediaimagepathmaindialog.cpp
index ff31fc6..1ba8a02 100644 (file)
@@ -55,12 +55,21 @@ void MediaImagePathMainDialog::connectSignals()
 void MediaImagePathMainDialog::initEditDialog()
 {
     nameDialog = new MediaImagePathDialog(this, dynamic_cast<FilePathObject*>(dbObject));
+    connectNameDialogSignals();
 }
 
 void MediaImagePathMainDialog::beginScanFilePath()
 {
     QModelIndex index = objectList->currentIndex();
     if (!index.isValid()) return;
+    if (QMessageBox::question(this,
+        tr("Confirm"),
+        tr("Do you want to continue? "
+        "If you have tons of huge files this may take even hours! "
+        "If you are low on battery power, consider carefully!"),
+        QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::No) {
+            return;
+        }
     FileUtil fileUtil(this);
     EmuFrontObject *ob = dbManager->getDataObjectFromModel(&index);
     if (!ob) return;
@@ -103,6 +112,22 @@ MediaImagePathMainDialog::~MediaImagePathMainDialog()
 
 void MediaImagePathMainDialog::deleteCurrentObject()
 {
-    delete dynamic_cast<FilePathObject*>(dbObject);
-    dbObject = 0;
+    if (dbObject) {
+        FilePathObject* fpo =  dynamic_cast<FilePathObject*>(dbObject);
+        if (fpo) delete fpo;
+        else qDebug() << "Failed deleteing FilePathObject";
+        dbObject = 0;
+    }
+}
+
+void MediaImagePathMainDialog::cleanUp()
+{
+    deleteCurrentObject();
+    if (nameDialog) {
+        MediaImagePathDialog *pnd =
+            dynamic_cast<MediaImagePathDialog*>(nameDialog);
+        if (pnd) delete pnd;
+        else qDebug() << "Failed to delete MediaImagePathDialog";
+        nameDialog = 0;
+    }
 }