aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/refactoringchanges.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2018-05-16 14:49:12 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2018-05-23 10:47:47 +0000
commit595f6980b774d899d349c70d31e43329a6359a5c (patch)
treede6e94c379d8c85e54ff2bec8d5021bf4d94630a /src/plugins/texteditor/refactoringchanges.cpp
parent36b835ff0ac1f6ab7b2ae8aab789352a9e297c21 (diff)
ClangTools: Reflect state of fixits
...in the fixit column to avoid confusion. As a side effect, add some error handling. Change-Id: Ia30e9c9782f3c8021aedd2be7c682853a26d3f39 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/texteditor/refactoringchanges.cpp')
-rw-r--r--src/plugins/texteditor/refactoringchanges.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index 93f53012eca..5905fb5f681 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -321,7 +321,7 @@ void RefactoringFile::setOpenEditor(bool activate, int pos)
m_editorCursorPosition = pos;
}
-void RefactoringFile::apply()
+bool RefactoringFile::apply()
{
// test file permissions
if (!QFileInfo(fileName()).isWritable()) {
@@ -331,7 +331,7 @@ void RefactoringFile::apply()
"Refactoring cannot be applied.");
roDialog.setShowFailWarning(true, failDetailText);
if (roDialog.exec() == ReadOnlyFilesDialog::RO_Cancel)
- return;
+ return false;
}
// open / activate / goto position
@@ -345,6 +345,8 @@ void RefactoringFile::apply()
m_editorCursorPosition = -1;
}
+ bool result = true;
+
// apply changes, if any
if (m_data && !(m_indentRanges.isEmpty() && m_changes.isEmpty())) {
QTextDocument *doc = mutableDocument();
@@ -374,10 +376,12 @@ void RefactoringFile::apply()
// if this document doesn't have an editor, write the result to a file
if (!m_editor && m_textFileFormat.codec) {
- QTC_ASSERT(!m_fileName.isEmpty(), return);
+ QTC_ASSERT(!m_fileName.isEmpty(), return false);
QString error;
- if (!m_textFileFormat.writeFile(m_fileName, doc->toPlainText(), &error))
+ if (!m_textFileFormat.writeFile(m_fileName, doc->toPlainText(), &error)) {
qWarning() << "Could not apply changes to" << m_fileName << ". Error: " << error;
+ result = false;
+ }
}
fileChanged();
@@ -385,6 +389,7 @@ void RefactoringFile::apply()
}
m_appliedOnce = true;
+ return result;
}
void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,