┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-08-01 18:33:12 +0000
committerPeter Penz <[email protected]>2009-08-01 18:33:12 +0000
commit22718cef13818ab97d745530bb2b4a6826053520 (patch)
treed9c805dda89b904c57d5b144f2e875a60d9d5b2a
parent0706af30c0e08c105e86d49f310f9f0e0f13c3e6 (diff)
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
-rw-r--r--src/revisioncontrolplugin.cpp20
-rw-r--r--src/revisioncontrolplugin.h3
2 files changed, 14 insertions, 9 deletions
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 <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."));
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 <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