#include <kshell.h>
#include <kvbox.h>
#include <QDir>
-#include <QFile>
#include <QLabel>
#include <QProcess>
#include <QString>
m_errorMsg(),
m_operationCompletedMsg(),
m_contextDir(),
- m_contextItems()
+ m_contextItems(),
+ m_tempFile()
{
m_updateAction = new KAction(this);
m_updateAction->setIcon(KIcon("view-refresh"));
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."));