forked from qt-creator/qt-creator
EnvironmentKitAspect: Distangle VSLANG related code
Avoid funny side effect in "currentEnvironment". Explicitly update the `Force UTF-8 MSVC compiler output` check box on initialization, and when the user edited the environment. Fixes: QTCREATORBUG-29382 Fixes: QTCREATORBUG-29425 Change-Id: I2b2615fa392ef0e4ee087d86207302b149a10768 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -1377,6 +1377,17 @@ void BuildDeviceKitAspect::devicesChanged()
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// EnvironmentKitAspect:
|
// EnvironmentKitAspect:
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
static EnvironmentItem forceMSVCEnglishItem()
|
||||||
|
{
|
||||||
|
static EnvironmentItem item("VSLANG", "1033");
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool enforcesMSVCEnglish(const EnvironmentItems &changes)
|
||||||
|
{
|
||||||
|
return changes.contains(forceMSVCEnglishItem());
|
||||||
|
}
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class EnvironmentKitAspectWidget final : public KitAspectWidget
|
class EnvironmentKitAspectWidget final : public KitAspectWidget
|
||||||
{
|
{
|
||||||
@@ -1411,7 +1422,7 @@ private:
|
|||||||
|
|
||||||
void refresh() override
|
void refresh() override
|
||||||
{
|
{
|
||||||
const EnvironmentItems changes = currentEnvironment();
|
const EnvironmentItems changes = envWithoutMSVCEnglishEnforcement();
|
||||||
const QString shortSummary = EnvironmentItem::toStringList(changes).join("; ");
|
const QString shortSummary = EnvironmentItem::toStringList(changes).join("; ");
|
||||||
m_summaryLabel->setText(shortSummary.isEmpty() ? Tr::tr("No changes to apply.") : shortSummary);
|
m_summaryLabel->setText(shortSummary.isEmpty() ? Tr::tr("No changes to apply.") : shortSummary);
|
||||||
}
|
}
|
||||||
@@ -1423,32 +1434,29 @@ private:
|
|||||||
VariableChooser::addSupportForChildWidgets(w, expander);
|
VariableChooser::addSupportForChildWidgets(w, expander);
|
||||||
};
|
};
|
||||||
auto changes = EnvironmentDialog::getEnvironmentItems(m_summaryLabel,
|
auto changes = EnvironmentDialog::getEnvironmentItems(m_summaryLabel,
|
||||||
currentEnvironment(),
|
envWithoutMSVCEnglishEnforcement(),
|
||||||
QString(),
|
QString(),
|
||||||
polisher);
|
polisher);
|
||||||
if (!changes)
|
if (!changes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (HostOsInfo::isWindowsHost()) {
|
if (HostOsInfo::isWindowsHost()) {
|
||||||
const EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033");
|
// re-add what envWithoutMSVCEnglishEnforcement removed
|
||||||
if (m_vslangCheckbox->isChecked() && changes->indexOf(forceMSVCEnglishItem) < 0)
|
// or update vslang checkbox if user added it manually
|
||||||
changes->append(forceMSVCEnglishItem);
|
if (m_vslangCheckbox->isChecked() && !enforcesMSVCEnglish(*changes))
|
||||||
|
changes->append(forceMSVCEnglishItem());
|
||||||
|
else if (enforcesMSVCEnglish(*changes))
|
||||||
|
m_vslangCheckbox->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvironmentKitAspect::setEnvironmentChanges(m_kit, *changes);
|
EnvironmentKitAspect::setEnvironmentChanges(m_kit, *changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvironmentItems currentEnvironment() const
|
EnvironmentItems envWithoutMSVCEnglishEnforcement() const
|
||||||
{
|
{
|
||||||
EnvironmentItems changes = EnvironmentKitAspect::environmentChanges(m_kit);
|
EnvironmentItems changes = EnvironmentKitAspect::environmentChanges(m_kit);
|
||||||
|
|
||||||
if (HostOsInfo::isWindowsHost()) {
|
if (HostOsInfo::isWindowsHost())
|
||||||
const EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033");
|
changes.removeAll(forceMSVCEnglishItem());
|
||||||
if (changes.indexOf(forceMSVCEnglishItem) >= 0) {
|
|
||||||
m_vslangCheckbox->setCheckState(Qt::Checked);
|
|
||||||
changes.removeAll(forceMSVCEnglishItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sorted(std::move(changes), [](const EnvironmentItem &lhs, const EnvironmentItem &rhs)
|
return sorted(std::move(changes), [](const EnvironmentItem &lhs, const EnvironmentItem &rhs)
|
||||||
{ return QString::localeAwareCompare(lhs.name, rhs.name) < 0; });
|
{ return QString::localeAwareCompare(lhs.name, rhs.name) < 0; });
|
||||||
@@ -1461,13 +1469,14 @@ private:
|
|||||||
m_vslangCheckbox->setToolTip(Tr::tr("Either switches MSVC to English or keeps the language and "
|
m_vslangCheckbox->setToolTip(Tr::tr("Either switches MSVC to English or keeps the language and "
|
||||||
"just forces UTF-8 output (may vary depending on the used MSVC "
|
"just forces UTF-8 output (may vary depending on the used MSVC "
|
||||||
"compiler)."));
|
"compiler)."));
|
||||||
connect(m_vslangCheckbox, &QCheckBox::toggled, this, [this](bool checked) {
|
if (enforcesMSVCEnglish(EnvironmentKitAspect::environmentChanges(m_kit)))
|
||||||
|
m_vslangCheckbox->setChecked(true);
|
||||||
|
connect(m_vslangCheckbox, &QCheckBox::clicked, this, [this](bool checked) {
|
||||||
EnvironmentItems changes = EnvironmentKitAspect::environmentChanges(m_kit);
|
EnvironmentItems changes = EnvironmentKitAspect::environmentChanges(m_kit);
|
||||||
const EnvironmentItem forceMSVCEnglishItem("VSLANG", "1033");
|
if (!checked && changes.indexOf(forceMSVCEnglishItem()) >= 0)
|
||||||
if (!checked && changes.indexOf(forceMSVCEnglishItem) >= 0)
|
changes.removeAll(forceMSVCEnglishItem());
|
||||||
changes.removeAll(forceMSVCEnglishItem);
|
if (checked && changes.indexOf(forceMSVCEnglishItem()) < 0)
|
||||||
if (checked && changes.indexOf(forceMSVCEnglishItem) < 0)
|
changes.append(forceMSVCEnglishItem());
|
||||||
changes.append(forceMSVCEnglishItem);
|
|
||||||
EnvironmentKitAspect::setEnvironmentChanges(m_kit, changes);
|
EnvironmentKitAspect::setEnvironmentChanges(m_kit, changes);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user