From 2909e09373ddf9c1e79ff6e462db6f0d7b40d89c Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 5 Aug 2011 21:37:28 +0100 Subject: [PATCH] Missed off previous commit An errant git rebase lost these changes, this is to support the GTC export file support and updates the Json parser to use the new call semantics and gets the Import wizard to clear up temporary files when it closes. --- src/JsonRideFile.y | 2 +- src/RideImportWizard.cpp | 23 ++++------------------- src/RideImportWizard.h | 2 ++ 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/JsonRideFile.y b/src/JsonRideFile.y index 98a5e714c..ef9ab0fa1 100644 --- a/src/JsonRideFile.y +++ b/src/JsonRideFile.y @@ -229,7 +229,7 @@ static int jsonFileReaderRegistered = "json", "GoldenCheetah Json Format", new JsonFileReader()); RideFile * -JsonFileReader::openRideFile(QFile &file, QStringList &errors) const +JsonFileReader::openRideFile(QFile &file, QStringList &errors, QList*) const { // jsonRide is local and static, used in the parser // JsonRideFilein is the FILE * used by the lexer diff --git a/src/RideImportWizard.cpp b/src/RideImportWizard.cpp index 7c2dbe4fe..312bcb755 100644 --- a/src/RideImportWizard.cpp +++ b/src/RideImportWizard.cpp @@ -34,6 +34,7 @@ // drag and drop passes urls ... convert to a list of files and call main constructor RideImportWizard::RideImportWizard(QList *urls, QDir &home, MainWindow *main, QWidget *parent) : QDialog(parent), mainWindow(main) { + setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); QList filenames; for (int i=0; icount(); i++) @@ -303,6 +304,7 @@ RideImportWizard::process() TcxFileReader reader; QFile target(fulltarget); reader.writeRideFile(mainWindow, mainWindow->cyclist, extracted, target); + deleteMe.append(fulltarget); // now add each temporary file ... filenames.insert(here, fulltarget); @@ -867,27 +869,10 @@ RideImportWizard::abortClicked() aborted = false; } -// destructor - not sure it ever gets called tho, even by RideImportWizard::done() +// clean up files RideImportWizard::~RideImportWizard() { - // Fill in the filenames and all the textItems - for (int i=0; i < filenames.count(); i++) { - QTableWidgetItem *t; - t = tableWidget->item(i,0); delete t; - t = tableWidget->item(i,1); delete t; - t = tableWidget->item(i,2); delete t; - t = tableWidget->item(i,3); delete t; - t = tableWidget->item(i,4); delete t; - t = tableWidget->item(i,5); delete t; - } - delete tableWidget; - filenames.clear(); - delete phaseLabel; - delete progressBar; - delete abortButton; - delete cancelButton; - delete todayButton; - delete overFiles; + foreach(QString name, deleteMe) QFile(name).remove(); } diff --git a/src/RideImportWizard.h b/src/RideImportWizard.h index 747bed84a..6de5af2ec 100644 --- a/src/RideImportWizard.h +++ b/src/RideImportWizard.h @@ -67,6 +67,8 @@ private: QCheckBox *overFiles; // chance to set overwrite when asking for dates bool overwriteFiles; // flag to overwrite files from checkbox MainWindow *mainWindow; // caller + + QStringList deleteMe; // list of temp files created during import }; // Item Delegate for Editing Date and Time of Ride inside the