From: Peter Penz Date: Sat, 1 Aug 2009 18:33:12 +0000 (+0000) Subject: Use QTemporaryFile instead of QFile. This assures an automatic deleting of the file... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/22718cef13818ab97d745530bb2b4a6826053520 Use QTemporaryFile instead of QFile. This assures an automatic deleting of the file and works reliable on multiuser system. Thanks to André Wöbbeking for the hint! svn path=/trunk/KDE/kdebase/apps/; revision=1005674 --- diff --git a/src/revisioncontrolplugin.cpp b/src/revisioncontrolplugin.cpp index 77a7b1290..683398879 100644 --- a/src/revisioncontrolplugin.cpp +++ b/src/revisioncontrolplugin.cpp @@ -40,7 +40,6 @@ RevisionControlPlugin::~RevisionControlPlugin() #include #include #include -#include #include #include #include @@ -60,7 +59,8 @@ SubversionPlugin::SubversionPlugin() : m_errorMsg(), m_operationCompletedMsg(), m_contextDir(), - m_contextItems() + m_contextItems(), + m_tempFile() { m_updateAction = new KAction(this); m_updateAction->setIcon(KIcon("view-refresh")); @@ -273,19 +273,21 @@ void SubversionPlugin::commitFiles() dialog.restoreDialogSize(dialogConfig); if (dialog.exec() == QDialog::Accepted) { - // write the commit description into a temporary file, so - // that it can be read by the command "svn commit -F" - QFile file(QDir::tempPath() + "/svn_commit_descr.txt"); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + // Write the commit description into a temporary file, so + // that it can be read by the command "svn commit -F". The temporary + // file must stay alive until slotOperationCompleted() is invoked and will + // be destroyed when the revision plugin is destructed. + if (!m_tempFile.open()) { emit errorMessage(i18nc("@info:status", "Commit of SVN changes failed.")); return; } - QTextStream out(&file); + QTextStream out(&m_tempFile); + const QString fileName = m_tempFile.fileName(); out << editor->toPlainText(); - file.close(); + m_tempFile.close(); - execSvnCommand("commit -F " + KShell::quoteArg(file.fileName()), + execSvnCommand("commit -F " + KShell::quoteArg(fileName), i18nc("@info:status", "Committing SVN changes..."), i18nc("@info:status", "Commit of SVN changes failed."), i18nc("@info:status", "Committed SVN changes.")); diff --git a/src/revisioncontrolplugin.h b/src/revisioncontrolplugin.h index b72968504..d9767cf74 100644 --- a/src/revisioncontrolplugin.h +++ b/src/revisioncontrolplugin.h @@ -166,6 +166,7 @@ signals: #include #include +#include class LIBDOLPHINPRIVATE_EXPORT SubversionPlugin : public RevisionControlPlugin { @@ -225,6 +226,8 @@ private: QString m_contextDir; KFileItemList m_contextItems; + + QTemporaryFile m_tempFile; }; #endif // REVISIONCONTROLPLUGIN_H