aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Sokolovskii <artem.sokolovskii@qt.io>2021-10-06 12:57:20 +0200
committerArtem Sokolovskii <artem.sokolovskii@qt.io>2021-10-06 13:17:04 +0000
commitd02155f24a918d02d4ddcdde8cc7e6f11fcce5b8 (patch)
treea9bddbc12e3a0e5be4af456253d578cc075a3bc4
parent25a7f30ffc8fcfc75040949e95d64e866653a10e (diff)
ClangFormat: Fix bug with reload of settings
- Fixed behavior when saved data from file doesn't load in the first opening of the code style options Change-Id: I1c72845cbf8119f9eb402a2f40bcc816c5590c25 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/plugins/clangformat/clangformatconfigwidget.cpp3
-rw-r--r--src/plugins/clangformat/clangformatfile.cpp2
2 files changed, 1 insertions, 4 deletions
diff --git a/src/plugins/clangformat/clangformatconfigwidget.cpp b/src/plugins/clangformat/clangformatconfigwidget.cpp
index 2749b1cf11..0dc6d4c54f 100644
--- a/src/plugins/clangformat/clangformatconfigwidget.cpp
+++ b/src/plugins/clangformat/clangformatconfigwidget.cpp
@@ -382,9 +382,6 @@ void ClangFormatConfigWidget::fillTable()
void ClangFormatConfigWidget::saveChanges(QObject *sender)
{
- std::stringstream content;
- content << "---";
-
if (sender->objectName() == "BasedOnStyle") {
const auto *basedOnStyle = m_checksWidget->findChild<QComboBox *>("BasedOnStyle");
m_config->setBasedOnStyle(basedOnStyle->currentText());
diff --git a/src/plugins/clangformat/clangformatfile.cpp b/src/plugins/clangformat/clangformatfile.cpp
index 31f096ed6f..8e532ea797 100644
--- a/src/plugins/clangformat/clangformatfile.cpp
+++ b/src/plugins/clangformat/clangformatfile.cpp
@@ -36,6 +36,7 @@ ClangFormatFile::ClangFormatFile(Utils::FilePath filePath)
return;
}
+ m_style.Language = clang::format::FormatStyle::LK_Cpp;
const std::error_code error
= clang::format::parseConfiguration(m_filePath.fileContents().toStdString(), &m_style);
if (error.value() != static_cast<int>(clang::format::ParseError::Success)) {
@@ -72,7 +73,6 @@ void ClangFormatFile::setBasedOnStyle(QString styleName)
QString ClangFormatFile::setStyle(QString style)
{
- m_style.Language = clang::format::FormatStyle::LK_Cpp;
const std::error_code error = clang::format::parseConfiguration(style.toStdString(), &m_style);
if (error.value() != static_cast<int>(clang::format::ParseError::Success)) {
return QString::fromStdString(error.message());