From 4103adf75d2958f043ef1da55c237de53e3b29f0 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sun, 3 Aug 2014 18:03:13 +0200 Subject: [PATCH] Re #1567: introduced unlink() function that takes QString parameter --- companion/src/burnconfigdialog.cpp | 2 +- companion/src/comparedialog.cpp | 8 ++------ companion/src/helpers.cpp | 7 +++++++ companion/src/helpers.h | 3 +++ companion/src/mainwindow.cpp | 6 +++--- companion/src/mdichild.cpp | 4 +--- companion/src/printdialog.cpp | 8 ++------ 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/companion/src/burnconfigdialog.cpp b/companion/src/burnconfigdialog.cpp index b4b865adf..2ccf4609a 100644 --- a/companion/src/burnconfigdialog.cpp +++ b/companion/src/burnconfigdialog.cpp @@ -376,7 +376,7 @@ void burnConfigDialog::restFuses(bool eeProtect) lfuses="lfuse:w:0x3F:m"; } file.close(); - unlink(tempFile.toAscii()); + unlink(tempFile); } else { lfuses="lfuse:w:0x3F:m"; diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index d6eb436ac..94197c382 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -156,12 +156,8 @@ void CompareDialog::dropEvent(QDropEvent *event) void CompareDialog::closeEvent(QCloseEvent *event) { - QByteArray ba = curvefile5.toLatin1(); - char *name = ba.data(); - unlink(name); - ba = curvefile9.toLatin1(); - name = ba.data(); - unlink(name); + unlink(curvefile5); + unlink(curvefile9); } CompareDialog::~CompareDialog() diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 8263f8035..f726949db 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -964,3 +964,10 @@ QString index2version(int index) return QString(); } } + + +int unlink(const QString & fileName) +{ + QByteArray ba = fileName.toLatin1(); + return unlink(ba.constData()); +} diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 9f735870a..5d33e1a0a 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -139,4 +139,7 @@ class QTimeS : public QTime int seconds() const { return hour()*3600 + minute()*60 + second(); }; }; + +int unlink(const QString & fileName); + #endif // HELPERS_H diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index a50a01152..d48be68bb 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -806,7 +806,7 @@ QStringList MainWindow::GetSambaArguments(const QString &tcl) QString tclFilename = QDir::tempPath() + "/temp.tcl"; if (QFile::exists(tclFilename)) { - unlink(tclFilename.toAscii()); + unlink(tclFilename); } QFile tclFile(tclFilename); if (!tclFile.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -963,7 +963,7 @@ void MainWindow::readEeprom() child->newFile(); child->loadFile(tempFile, false); child->show(); - unlink(tempFile.toAscii()); + unlink(tempFile); } } @@ -1194,7 +1194,7 @@ void MainWindow::writeBackup() } fileName = restoreFile; } - unlink(tempFlash.toAscii()); + unlink(tempFlash); } else { if (backupEnable) { diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 03a7b5ddc..a62be58e0 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -571,9 +571,7 @@ void MdiChild::writeEeprom() // write to Tx } tempFile=restoreFile; } - QByteArray ba = tempFlash.toLatin1(); - char *name = ba.data(); - unlink(name); + unlink(tempFlash); } else { if (backupEnable) { diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index eee4816da..2e8d281b1 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -61,12 +61,8 @@ PrintDialog::PrintDialog(QWidget *parent, FirmwareInterface * firmware, GeneralS void PrintDialog::closeEvent(QCloseEvent *event) { if (printfilename.isEmpty()) { - QByteArray ba = curvefile5.toLatin1(); - char *name = ba.data(); - unlink(name); - ba = curvefile9.toLatin1(); - name = ba.data(); - unlink(name); + unlink(curvefile5); + unlink(curvefile9); } }