forked from qt-creator/qt-creator
TextEditor: Make RefactoringFile::apply() a no-op for empty change sets
To simplify some calling sites. Change-Id: I9736e88053659e5e90bca7b70e6d7e84b0d4fb4e Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -307,10 +307,8 @@ public:
|
|||||||
insertAndIndent(m_sourceFile, m_sourceFileInsertionPoint, m_sourceFileCode);
|
insertAndIndent(m_sourceFile, m_sourceFileInsertionPoint, m_sourceFileCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_headerFileChangeSet.isEmpty())
|
m_headerFile->apply(m_headerFileChangeSet);
|
||||||
m_headerFile->apply(m_headerFileChangeSet);
|
m_sourceFile->apply(m_sourceFileChangeSet);
|
||||||
if (!m_sourceFileChangeSet.isEmpty())
|
|
||||||
m_sourceFile->apply(m_sourceFileChangeSet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasSourceFile() const { return m_headerFile != m_sourceFile; }
|
bool hasSourceFile() const { return m_headerFile != m_sourceFile; }
|
||||||
|
@@ -920,8 +920,7 @@ public:
|
|||||||
implementationChangeSet.insert(insertPos, QLatin1String("\n\n") + defText);
|
implementationChangeSet.insert(insertPos, QLatin1String("\n\n") + defText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!implementationChangeSet.isEmpty())
|
implementationFile->apply(implementationChangeSet);
|
||||||
implementationFile->apply(implementationChangeSet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -135,10 +135,8 @@ public:
|
|||||||
|
|
||||||
void applyChanges()
|
void applyChanges()
|
||||||
{
|
{
|
||||||
if (!m_toFileChangeSet.isEmpty())
|
m_toFile->apply(m_toFileChangeSet);
|
||||||
m_toFile->apply(m_toFileChangeSet);
|
m_fromFile->apply(m_fromFileChangeSet);
|
||||||
if (!m_fromFileChangeSet.isEmpty())
|
|
||||||
m_fromFile->apply(m_fromFileChangeSet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -214,6 +214,9 @@ void RefactoringFile::setOpenEditor(bool activate, int pos)
|
|||||||
|
|
||||||
bool RefactoringFile::apply()
|
bool RefactoringFile::apply()
|
||||||
{
|
{
|
||||||
|
if (m_changes.isEmpty())
|
||||||
|
return true;
|
||||||
|
|
||||||
// test file permissions
|
// test file permissions
|
||||||
if (!m_filePath.isWritableFile()) {
|
if (!m_filePath.isWritableFile()) {
|
||||||
ReadOnlyFilesDialog roDialog(m_filePath, ICore::dialogParent());
|
ReadOnlyFilesDialog roDialog(m_filePath, ICore::dialogParent());
|
||||||
|
Reference in New Issue
Block a user