From: Mikko Keinänen Date: Sun, 14 Nov 2010 21:16:16 +0000 (+0200) Subject: Bug fixed: media images were not removed from temporary file folder. X-Git-Url: http://git.maemo.org/git/?a=commitdiff_plain;h=1f652abbee008f6130a6fec4df6839de583ac27a;hp=97d97d84592a5b65202892c5e6db216ec665c80a;p=emufront Bug fixed: media images were not removed from temporary file folder. --- diff --git a/src/emulauncher.cpp b/src/emulauncher.cpp index 23e8b0e..c6403e9 100644 --- a/src/emulauncher.cpp +++ b/src/emulauncher.cpp @@ -224,7 +224,9 @@ void EmuLauncher::launchEmu() throw EmuFrontException(tr("Select %1 media images for this emulator configuration").arg(list.count())); } if (list.count() > 1) { + // more than one placeholder for media image in the command line ($1, $2, ...) int lim = list.count() == mediaImages.count() ? list.count() - 1 : list.count(); + // user sets the order of media images for(int i = 0; i < lim; i++) { EmuFrontObject *efo = EmuFrontInputDialog::getItem( this, tr("Select image no. %1").arg(i+1), tr("Select"), mediaImages.values(), 0, false, &ok); @@ -236,10 +238,10 @@ void EmuLauncher::launchEmu() QString key = mi->getCheckSum(); mediaImages.remove(key); } - if (mediaImages.count() == 1) { - // there should be at least one media image left in mediaImages map + // there should be at least one media image left in mediaImages map... + /*if (mediaImages.count() == 1) { selectedImages << mediaImages.values().first(); - } + } ... this is added later-> */ } else if (mediaImages.count() > 1) { // show select boot image dialog @@ -249,15 +251,27 @@ void EmuLauncher::launchEmu() throw EmuFrontException(tr("Boot image selection was canceled, aborting.")); } selectedImages << efo; + MediaImage *mi = dynamic_cast(efo); + QString key = mi->getCheckSum(); + mediaImages.remove(key); + } + else if (mediaImages.count() == 1) { + EmuFrontObject *efo = mediaImages.values().first(); + selectedImages << efo; + MediaImage *mi = dynamic_cast(efo); + QString key = mi->getCheckSum(); + mediaImages.remove(key); + } + // in all the both cases the (ordered) list of media images will be passed to emuHelper + + // wee also keep the rest of the mediaimages in the selected containers for reference! + foreach(EmuFrontObject *efo, mediaImages) { + selectedImages << efo; } - else if (mediaImages.count() == 1) - selectedImages << mediaImages.values().first(); - // in the both cases the (ordered) list of media images will be passed to emuHelper if (selectedImages.count() < 1) throw EmuFrontException(tr("No media images selected")); - emuHelper->launch(exe, mediaImageContainers, selectedImages, list.count(), tmpDirPath); micTable->clearSelection(); } catch (EmuFrontException efe) { diff --git a/src/utils/emuhelper.cpp b/src/utils/emuhelper.cpp index 6642a40..a816acc 100644 --- a/src/utils/emuhelper.cpp +++ b/src/utils/emuhelper.cpp @@ -112,26 +112,27 @@ void EmuHelper::launch(const Executable * ex, QList micLi waitForFinished(-1); try { - QDir ftmp(tmp); - if (!ftmp.exists()) { - throw EmuFrontException(tr("Trying to remove temporary files. " - "Directory %s doesn't exist!").arg(tmp)); - } - // clean the temp dir - foreach(EmuFrontObject *ob, miList) { - if (!ftmp.exists(ob->getName())) { - qDebug() << "File " << ob->getName() << " doesn't exist in " << tmp; - continue; - } - QString fp = ftmp.filePath(ob->getName()); - QFile f(fp); - if (!f.exists()) { - qDebug() << "File " << fp << " doesn't exist!"; + QDir ftmp(tmp); + if (!ftmp.exists()) { + throw EmuFrontException(tr("Trying to remove temporary files. " + "Directory %s doesn't exist!").arg(tmp)); } - if (!f.remove()) { - qDebug() << "Removing " << fp << " failed."; + // clean the temp dir + // TODO: if selected archive with multiple items, the files are not removed! + foreach(EmuFrontObject *ob, miList) { + if (!ftmp.exists(ob->getName())) { + qDebug() << "File " << ob->getName() << " doesn't exist in " << tmp; + continue; + } + QString fp = ftmp.filePath(ob->getName()); + QFile f(fp); + if (!f.exists()) { + qDebug() << "File " << fp << " doesn't exist!"; + } + if (!f.remove()) { + qDebug() << "Removing " << fp << " failed."; + } } - } } catch (EmuFrontException e) { qDebug() << e.what(); }