forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -382,9 +382,6 @@ void ClangFormatConfigWidget::fillTable()
|
|||||||
|
|
||||||
void ClangFormatConfigWidget::saveChanges(QObject *sender)
|
void ClangFormatConfigWidget::saveChanges(QObject *sender)
|
||||||
{
|
{
|
||||||
std::stringstream content;
|
|
||||||
content << "---";
|
|
||||||
|
|
||||||
if (sender->objectName() == "BasedOnStyle") {
|
if (sender->objectName() == "BasedOnStyle") {
|
||||||
const auto *basedOnStyle = m_checksWidget->findChild<QComboBox *>("BasedOnStyle");
|
const auto *basedOnStyle = m_checksWidget->findChild<QComboBox *>("BasedOnStyle");
|
||||||
m_config->setBasedOnStyle(basedOnStyle->currentText());
|
m_config->setBasedOnStyle(basedOnStyle->currentText());
|
||||||
|
@@ -36,6 +36,7 @@ ClangFormatFile::ClangFormatFile(Utils::FilePath filePath)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_style.Language = clang::format::FormatStyle::LK_Cpp;
|
||||||
const std::error_code error
|
const std::error_code error
|
||||||
= clang::format::parseConfiguration(m_filePath.fileContents().toStdString(), &m_style);
|
= clang::format::parseConfiguration(m_filePath.fileContents().toStdString(), &m_style);
|
||||||
if (error.value() != static_cast<int>(clang::format::ParseError::Success)) {
|
if (error.value() != static_cast<int>(clang::format::ParseError::Success)) {
|
||||||
@@ -72,7 +73,6 @@ void ClangFormatFile::setBasedOnStyle(QString styleName)
|
|||||||
|
|
||||||
QString ClangFormatFile::setStyle(QString style)
|
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);
|
const std::error_code error = clang::format::parseConfiguration(style.toStdString(), &m_style);
|
||||||
if (error.value() != static_cast<int>(clang::format::ParseError::Success)) {
|
if (error.value() != static_cast<int>(clang::format::ParseError::Success)) {
|
||||||
return QString::fromStdString(error.message());
|
return QString::fromStdString(error.message());
|
||||||
|
Reference in New Issue
Block a user