]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use QTemporaryFile instead of QFile. This assures an automatic deleting of the file...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 1 Aug 2009 18:33:12 +0000 (18:33 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 1 Aug 2009 18:33:12 +0000 (18:33 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1005674

src/revisioncontrolplugin.cpp
src/revisioncontrolplugin.h

index 77a7b1290427c966e9059b685e305784cbd0d48a..683398879f4102bfd4762db45cbc65a878737272 100644 (file)
@@ -40,7 +40,6 @@ RevisionControlPlugin::~RevisionControlPlugin()
 #include <kshell.h>
 #include <kvbox.h>
 #include <QDir>
-#include <QFile>
 #include <QLabel>
 #include <QProcess>
 #include <QString>
@@ -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."));
index b72968504936a2f1a6d31fa3d7ed605b78a5ec5d..d9767cf746e72e0727fd4cc37e10cbdf7d306715 100644 (file)
@@ -166,6 +166,7 @@ signals:
 
 #include <kfileitem.h>
 #include <QHash>
+#include <QTemporaryFile>
 
 class LIBDOLPHINPRIVATE_EXPORT SubversionPlugin : public RevisionControlPlugin
 {
@@ -225,6 +226,8 @@ private:
 
     QString m_contextDir;
     KFileItemList m_contextItems;
+
+    QTemporaryFile m_tempFile;
 };
 #endif // REVISIONCONTROLPLUGIN_H