From 5aa65b12f34768def100b8a4bec0a0e16f46c0fd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Tue, 22 Sep 2009 12:23:44 +0200 Subject: [PATCH] Version control: Do not keep lock on message file while committing. Store the file name and do not keep the QTemporaryFile around, which still seems to maintain some kind of lock on Windows although it is closed. --- src/plugins/cvs/cvsplugin.cpp | 50 ++++++++++---------- src/plugins/cvs/cvsplugin.h | 6 +-- src/plugins/git/gitplugin.cpp | 47 ++++++++++--------- src/plugins/git/gitplugin.h | 6 +-- src/plugins/perforce/perforceplugin.cpp | 52 +++++++++++---------- src/plugins/perforce/perforceplugin.h | 7 +-- src/plugins/subversion/subversionplugin.cpp | 49 +++++++++---------- src/plugins/subversion/subversionplugin.h | 6 +-- 8 files changed, 116 insertions(+), 107 deletions(-) diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 508cb9e78ed..abe055554c8 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -58,9 +58,9 @@ #include <QtCore/QDate> #include <QtCore/QDir> #include <QtCore/QFileInfo> -#include <QtCore/QTemporaryFile> #include <QtCore/QTextCodec> #include <QtCore/QtPlugin> +#include <QtCore/QTemporaryFile> #include <QtGui/QAction> #include <QtGui/QMainWindow> #include <QtGui/QMenu> @@ -151,7 +151,6 @@ CVSPlugin *CVSPlugin::m_cvsPluginInstance = 0; CVSPlugin::CVSPlugin() : m_versionControl(0), - m_changeTmpFile(0), m_projectExplorer(0), m_addAction(0), m_deleteAction(0), @@ -174,18 +173,20 @@ CVSPlugin::CVSPlugin() : CVSPlugin::~CVSPlugin() { - cleanChangeTmpFile(); + cleanCommitMessageFile(); } -void CVSPlugin::cleanChangeTmpFile() +void CVSPlugin::cleanCommitMessageFile() { - if (m_changeTmpFile) { - if (m_changeTmpFile->isOpen()) - m_changeTmpFile->close(); - delete m_changeTmpFile; - m_changeTmpFile = 0; + if (!m_commitMessageFileName.isEmpty()) { + QFile::remove(m_commitMessageFileName); + m_commitMessageFileName.clear(); } } +bool CVSPlugin::isCommitEditorOpen() const +{ + return !m_commitMessageFileName.isEmpty(); +} static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = { CVS::Constants::CVS_SUBMIT_MIMETYPE, @@ -383,7 +384,7 @@ void CVSPlugin::extensionsInitialized() bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor) { - if (!m_changeTmpFile || !iEditor || qstrcmp(Constants::CVSCOMMITEDITOR, iEditor->kind())) + if (!iEditor || !isCommitEditorOpen() || qstrcmp(Constants::CVSCOMMITEDITOR, iEditor->kind())) return true; Core::IFile *fileIFace = iEditor->file(); @@ -394,7 +395,7 @@ bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor) // Submit editor closing. Make it write out the commit message // and retrieve files const QFileInfo editorFile(fileIFace->fileName()); - const QFileInfo changeFile(m_changeTmpFile->fileName()); + const QFileInfo changeFile(m_commitMessageFileName); if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath()) return true; // Oops?! @@ -411,7 +412,7 @@ bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor) case VCSBase::VCSBaseSubmitEditor::SubmitCanceled: return false; // Keep editing and change file case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded: - cleanChangeTmpFile(); + cleanCommitMessageFile(); return true; // Cancel all default: break; @@ -424,10 +425,10 @@ bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor) Core::ICore::instance()->fileManager()->blockFileChange(fileIFace); fileIFace->save(); Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace); - closeEditor= commit(m_changeTmpFile->fileName(), fileList); + closeEditor= commit(m_commitMessageFileName, fileList); } if (closeEditor) - cleanChangeTmpFile(); + cleanCommitMessageFile(); return closeEditor; } @@ -639,7 +640,7 @@ void CVSPlugin::startCommit(const QString &source) return; if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor()) return; - if (m_changeTmpFile) { + if (isCommitEditorOpen()) { VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed.")); return; } @@ -674,22 +675,21 @@ void CVSPlugin::startCommit(const QString &source) } // Create a new submit change file containing the submit template - QTemporaryFile *changeTmpFile = new QTemporaryFile(this); - changeTmpFile->setAutoRemove(true); - if (!changeTmpFile->open()) { - VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); - delete changeTmpFile; + QTemporaryFile changeTmpFile; + changeTmpFile.setAutoRemove(false); + if (!changeTmpFile.open()) { + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString())); return; } - m_changeTmpFile = changeTmpFile; // TODO: Retrieve submit template from const QString submitTemplate; + m_commitMessageFileName = changeTmpFile.fileName(); // Create a submit - m_changeTmpFile->write(submitTemplate.toUtf8()); - m_changeTmpFile->flush(); - m_changeTmpFile->close(); + changeTmpFile.write(submitTemplate.toUtf8()); + changeTmpFile.flush(); + changeTmpFile.close(); // Create a submit editor and set file list - CVSSubmitEditor *editor = openCVSSubmitEditor(m_changeTmpFile->fileName()); + CVSSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName); editor->setStateList(statusOutput); } diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h index c111e1467ca..bac3815d861 100644 --- a/src/plugins/cvs/cvsplugin.h +++ b/src/plugins/cvs/cvsplugin.h @@ -39,7 +39,6 @@ QT_BEGIN_NAMESPACE class QDir; class QAction; -class QTemporaryFile; class QTextCodec; QT_END_NAMESPACE @@ -124,6 +123,7 @@ private slots: void diffFiles(const QStringList &); private: + bool isCommitEditorOpen() const; QString currentFileName() const; Core::IEditor * showOutputInEditor(const QString& title, const QString &output, int editorType, const QString &source, @@ -149,11 +149,11 @@ private: QStringList currentProjectsTopLevels(QString *name = 0) const; void startCommit(const QString &file); bool commit(const QString &messageFile, const QStringList &subVersionFileList); - void cleanChangeTmpFile(); + void cleanCommitMessageFile(); CVSSettings m_settings; Core::IVersionControl *m_versionControl; - QTemporaryFile *m_changeTmpFile; + QString m_commitMessageFileName; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 304d4a45f31..b61fc8f5caf 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -141,7 +141,6 @@ GitPlugin::GitPlugin() : m_projectExplorer(0), m_gitClient(0), m_changeSelectionDialog(0), - m_changeTmpFile(0), m_submitActionTriggered(false) { m_instance = this; @@ -149,19 +148,24 @@ GitPlugin::GitPlugin() : GitPlugin::~GitPlugin() { - cleanChangeTmpFile(); + cleanCommitMessageFile(); delete m_gitClient; m_instance = 0; } -void GitPlugin::cleanChangeTmpFile() +void GitPlugin::cleanCommitMessageFile() { - if (m_changeTmpFile) { - delete m_changeTmpFile; - m_changeTmpFile = 0; + if (!m_commitMessageFileName.isEmpty()) { + QFile::remove(m_commitMessageFileName); + m_commitMessageFileName.clear(); } } +bool GitPlugin::isCommitEditorOpen() const +{ + return !m_commitMessageFileName.isEmpty(); +} + GitPlugin *GitPlugin::instance() { return m_instance; @@ -555,7 +559,7 @@ void GitPlugin::startCommit() { if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor()) return; - if (m_changeTmpFile) { + if (isCommitEditorOpen()) { VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently being executed.")); return; } @@ -583,20 +587,19 @@ void GitPlugin::startCommit() qDebug() << Q_FUNC_INFO << data << commitTemplate; // Start new temp file with message template - QTemporaryFile *changeTmpFile = new QTemporaryFile(this); - changeTmpFile->setAutoRemove(true); - if (!changeTmpFile->open()) { - VCSBase::VCSBaseOutputWindow::instance()->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); - delete changeTmpFile; + QTemporaryFile changeTmpFile; + changeTmpFile.setAutoRemove(false); + if (!changeTmpFile.open()) { + VCSBase::VCSBaseOutputWindow::instance()->append(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString())); return; } - m_changeTmpFile = changeTmpFile; - m_changeTmpFile->write(commitTemplate.toLocal8Bit()); - m_changeTmpFile->flush(); + m_commitMessageFileName = changeTmpFile.fileName(); + changeTmpFile.write(commitTemplate.toLocal8Bit()); + changeTmpFile.flush(); // Keep the file alive, else it removes self and forgets // its name - m_changeTmpFile->close(); - openSubmitEditor(m_changeTmpFile->fileName(), data); + changeTmpFile.close(); + openSubmitEditor(m_commitMessageFileName, data); } Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd) @@ -627,7 +630,7 @@ void GitPlugin::submitCurrentLog() bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor) { // Closing a submit editor? - if (!m_changeTmpFile || !iEditor || qstrcmp(iEditor->kind(), Constants::GITSUBMITEDITOR_KIND)) + if (!iEditor || !isCommitEditorOpen() || qstrcmp(iEditor->kind(), Constants::GITSUBMITEDITOR_KIND)) return true; Core::IFile *fileIFace = iEditor->file(); const GitSubmitEditor *editor = qobject_cast<GitSubmitEditor *>(iEditor); @@ -636,7 +639,7 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor) // Submit editor closing. Make it write out the commit message // and retrieve files const QFileInfo editorFile(fileIFace->fileName()); - const QFileInfo changeFile(m_changeTmpFile->fileName()); + const QFileInfo changeFile(m_commitMessageFileName); // Paranoia! if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath()) return true; @@ -654,7 +657,7 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor) case VCSBase::VCSBaseSubmitEditor::SubmitCanceled: return false; // Keep editing and change file case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded: - cleanChangeTmpFile(); + cleanCommitMessageFile(); return true; // Cancel all default: break; @@ -674,13 +677,13 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor) closeEditor = m_gitClient->addAndCommit(m_submitRepository, editor->panelData(), - m_changeTmpFile->fileName(), + m_commitMessageFileName, fileList, m_submitOrigCommitFiles, m_submitOrigDeleteFiles); } if (closeEditor) - cleanChangeTmpFile(); + cleanCommitMessageFile(); return closeEditor; } diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 784fe883f50..bc3ed2aa550 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -44,7 +44,6 @@ QT_BEGIN_NAMESPACE class QFile; class QAction; -class QTemporaryFile; QT_END_NAMESPACE namespace Core { @@ -128,9 +127,10 @@ private slots: void push(); private: + bool isCommitEditorOpen() const; QFileInfo currentFile() const; Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd); - void cleanChangeTmpFile(); + void cleanCommitMessageFile(); static GitPlugin *m_instance; Core::ICore *m_core; @@ -166,7 +166,7 @@ private: QString m_submitRepository; QStringList m_submitOrigCommitFiles; QStringList m_submitOrigDeleteFiles; - QTemporaryFile *m_changeTmpFile; + QString m_commitMessageFileName; bool m_submitActionTriggered; }; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 5254f93d5d3..2c12882530e 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -189,7 +189,6 @@ PerforcePlugin::PerforcePlugin() : m_diffSelectedFiles(0), m_undoAction(0), m_redoAction(0), - m_changeTmpFile(0), m_versionControl(0) { } @@ -547,28 +546,29 @@ void PerforcePlugin::submit() return; } - if (m_changeTmpFile) { + if (isCommitEditorOpen()) { VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently executed.")); return; } - m_changeTmpFile = new QTemporaryFile(this); - m_changeTmpFile->setAutoRemove(true); - if (!m_changeTmpFile->open()) { + QTemporaryFile changeTmpFile; + changeTmpFile.setAutoRemove(false); + if (!changeTmpFile.open()) { VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file.")); - cleanChangeTmpFile(); + cleanCommitMessageFile(); return; } PerforceResponse result = runP4Cmd(QStringList()<< QLatin1String("change") << QLatin1String("-o"), QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow); if (result.error) { - cleanChangeTmpFile(); + cleanCommitMessageFile(); return; } - m_changeTmpFile->write(result.stdOut.toAscii()); - m_changeTmpFile->close(); + m_commitMessageFileName = changeTmpFile.fileName(); + changeTmpFile.write(result.stdOut.toAscii()); + changeTmpFile.close(); // Assemble file list of project QString name; @@ -576,7 +576,7 @@ void PerforcePlugin::submit() PerforceResponse result2 = runP4Cmd(QStringList(QLatin1String("fstat")), nativeFiles, CommandToWindow|StdErrToWindow|ErrorToWindow); if (result2.error) { - cleanChangeTmpFile(); + cleanCommitMessageFile(); return; } @@ -588,11 +588,11 @@ void PerforcePlugin::submit() } if (depotFileNames.isEmpty()) { VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Project has no files")); - cleanChangeTmpFile(); + cleanCommitMessageFile(); return; } - openPerforceSubmitEditor(m_changeTmpFile->fileName(), depotFileNames); + openPerforceSubmitEditor(m_commitMessageFileName, depotFileNames); } Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames) @@ -983,19 +983,22 @@ void PerforcePlugin::submitCurrentLog() em->closeEditors(QList<Core::IEditor*>() << em->currentEditor()); } -void PerforcePlugin::cleanChangeTmpFile() +void PerforcePlugin::cleanCommitMessageFile() { - if (m_changeTmpFile) { - if (m_changeTmpFile->isOpen()) - m_changeTmpFile->close(); - delete m_changeTmpFile; - m_changeTmpFile = 0; + if (!m_commitMessageFileName.isEmpty()) { + QFile::remove(m_commitMessageFileName); + m_commitMessageFileName.clear(); } } +bool PerforcePlugin::isCommitEditorOpen() const +{ + return !m_commitMessageFileName.isEmpty(); +} + bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) { - if (!m_changeTmpFile || !editor) + if (!editor || !isCommitEditorOpen()) return true; Core::ICore *core = Core::ICore::instance(); Core::IFile *fileIFace = editor->file(); @@ -1005,7 +1008,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) if (!perforceEditor) return true; QFileInfo editorFile(fileIFace->fileName()); - QFileInfo changeFile(m_changeTmpFile->fileName()); + QFileInfo changeFile(m_commitMessageFileName); if (editorFile.absoluteFilePath() == changeFile.absoluteFilePath()) { // Prompt the user. Force a prompt unless submit was actually invoked (that // is, the editor was closed or shutdown). @@ -1029,12 +1032,13 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) fileIFace->save(); core->fileManager()->unblockFileChange(fileIFace); if (answer == VCSBase::VCSBaseSubmitEditor::SubmitConfirmed) { - if (!m_changeTmpFile->open()) { + QFile commitMessageFile(m_commitMessageFileName); + if (!commitMessageFile.open(QIODevice::ReadOnly|QIODevice::Text)) { VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot open temporary file.")); return false; } - QByteArray change = m_changeTmpFile->readAll(); - m_changeTmpFile->close(); + QByteArray change = commitMessageFile.readAll(); + commitMessageFile.close(); QString errorMessage; if (!checkP4Configuration(&errorMessage)) { VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); @@ -1074,7 +1078,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) } QApplication::restoreOverrideCursor(); } - cleanChangeTmpFile(); + cleanCommitMessageFile(); } return true; } diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index 33098a81048..761fb96799c 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -45,7 +45,6 @@ QT_BEGIN_NAMESPACE class QFile; class QAction; -class QTemporaryFile; class QTextCodec; QT_END_NAMESPACE @@ -162,7 +161,9 @@ private: bool checkP4Configuration(QString *errorMessage = 0) const; void annotate(const QString &fileName); void filelog(const QString &fileName); - void cleanChangeTmpFile(); + void cleanCommitMessageFile(); + bool isCommitEditorOpen() const; + void updateCheckout(const QStringList &dirs = QStringList()); ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; @@ -188,11 +189,11 @@ private: QAction *m_updateAllAction; bool m_submitActionTriggered; QAction *m_diffSelectedFiles; + QString m_commitMessageFileName; QAction *m_undoAction; QAction *m_redoAction; - QTemporaryFile *m_changeTmpFile; static PerforcePlugin *m_perforcePluginInstance; QString pendingChangesData(); diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 718831c9d09..374ced568e9 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -180,7 +180,6 @@ SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0; SubversionPlugin::SubversionPlugin() : m_svnDirectories(svnDirectories()), m_versionControl(0), - m_changeTmpFile(0), m_projectExplorer(0), m_addAction(0), m_deleteAction(0), @@ -204,19 +203,22 @@ SubversionPlugin::SubversionPlugin() : SubversionPlugin::~SubversionPlugin() { - cleanChangeTmpFile(); + cleanCommitMessageFile(); } -void SubversionPlugin::cleanChangeTmpFile() +void SubversionPlugin::cleanCommitMessageFile() { - if (m_changeTmpFile) { - if (m_changeTmpFile->isOpen()) - m_changeTmpFile->close(); - delete m_changeTmpFile; - m_changeTmpFile = 0; + if (!m_commitMessageFileName.isEmpty()) { + QFile::remove(m_commitMessageFileName); + m_commitMessageFileName.clear(); } } +bool SubversionPlugin::isCommitEditorOpen() const +{ + return !m_commitMessageFileName.isEmpty(); +} + static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = { Subversion::Constants::SUBVERSION_SUBMIT_MIMETYPE, Subversion::Constants::SUBVERSIONCOMMITEDITOR_KIND, @@ -416,7 +418,7 @@ void SubversionPlugin::extensionsInitialized() bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor) { - if (!m_changeTmpFile || !iEditor || qstrcmp(Constants::SUBVERSIONCOMMITEDITOR, iEditor->kind())) + if ( !iEditor || !isCommitEditorOpen() || qstrcmp(Constants::SUBVERSIONCOMMITEDITOR, iEditor->kind())) return true; Core::IFile *fileIFace = iEditor->file(); @@ -427,7 +429,7 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor) // Submit editor closing. Make it write out the commit message // and retrieve files const QFileInfo editorFile(fileIFace->fileName()); - const QFileInfo changeFile(m_changeTmpFile->fileName()); + const QFileInfo changeFile(m_commitMessageFileName); if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath()) return true; // Oops?! @@ -444,7 +446,7 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor) case VCSBase::VCSBaseSubmitEditor::SubmitCanceled: return false; // Keep editing and change file case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded: - cleanChangeTmpFile(); + cleanCommitMessageFile(); return true; // Cancel all default: break; @@ -457,10 +459,10 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor) Core::ICore::instance()->fileManager()->blockFileChange(fileIFace); fileIFace->save(); Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace); - closeEditor= commit(m_changeTmpFile->fileName(), fileList); + closeEditor= commit(m_commitMessageFileName, fileList); } if (closeEditor) - cleanChangeTmpFile(); + cleanCommitMessageFile(); return closeEditor; } @@ -658,7 +660,7 @@ void SubversionPlugin::startCommit(const QStringList &files) return; if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor()) return; - if (m_changeTmpFile) { + if (isCommitEditorOpen()) { VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed.")); return; } @@ -679,22 +681,21 @@ void SubversionPlugin::startCommit(const QStringList &files) } // Create a new submit change file containing the submit template - QTemporaryFile *changeTmpFile = new QTemporaryFile(this); - changeTmpFile->setAutoRemove(true); - if (!changeTmpFile->open()) { - VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); - delete changeTmpFile; + QTemporaryFile changeTmpFile; + changeTmpFile.setAutoRemove(false); + if (!changeTmpFile.open()) { + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString())); return; } - m_changeTmpFile = changeTmpFile; + m_commitMessageFileName = changeTmpFile.fileName(); // TODO: Retrieve submit template from const QString submitTemplate; // Create a submit - m_changeTmpFile->write(submitTemplate.toUtf8()); - m_changeTmpFile->flush(); - m_changeTmpFile->close(); + changeTmpFile.write(submitTemplate.toUtf8()); + changeTmpFile.flush(); + changeTmpFile.close(); // Create a submit editor and set file list - SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_changeTmpFile->fileName()); + SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_commitMessageFileName); editor->setStatusList(statusOutput); } diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index fcfd6f7baab..b7bbc2f710a 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -38,7 +38,6 @@ QT_BEGIN_NAMESPACE class QDir; class QAction; -class QTemporaryFile; class QTextCodec; QT_END_NAMESPACE @@ -113,6 +112,7 @@ private slots: void diffFiles(const QStringList &); private: + inline bool isCommitEditorOpen() const; QString currentFileName() const; Core::IEditor * showOutputInEditor(const QString& title, const QString &output, int editorType, const QString &source, @@ -126,13 +126,13 @@ private: QStringList currentProjectsTopLevels(QString *name = 0) const; void startCommit(const QStringList &files); bool commit(const QString &messageFile, const QStringList &subVersionFileList); - void cleanChangeTmpFile(); + void cleanCommitMessageFile(); const QStringList m_svnDirectories; SubversionSettings m_settings; Core::IVersionControl *m_versionControl; - QTemporaryFile *m_changeTmpFile; + QString m_commitMessageFileName; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; -- GitLab