From 309640eb7ff6de5b463999a6d4d5087d0561403a Mon Sep 17 00:00:00 2001 From: Silas Date: Wed, 2 Jan 2019 22:26:57 -0200 Subject: [PATCH] Only changes the ViewSystem if the user confirms UnitsApi::setSchema() was being called when the user changed the comboBox item, so the view system was saved if the user later clicked Cancel. This call was moved to the saveSettings() method that is called only if the user clicks Apply or OK. --- src/Gui/DlgSettingsUnitsImp.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Gui/DlgSettingsUnitsImp.cpp b/src/Gui/DlgSettingsUnitsImp.cpp index ba12c0e451..a4a491944c 100644 --- a/src/Gui/DlgSettingsUnitsImp.cpp +++ b/src/Gui/DlgSettingsUnitsImp.cpp @@ -78,8 +78,6 @@ void DlgSettingsUnitsImp::on_comboBox_ViewSystem_currentIndexChanged(int index) if (index < 0) return; // happens when clearing the combo box in retranslateUi() - UnitsApi::setSchema((UnitSystem)index); - // Enable/disable the fractional inch option depending on system if( (UnitSystem)index == ImperialBuilding ) { @@ -96,6 +94,7 @@ void DlgSettingsUnitsImp::saveSettings() // must be done as very first because we create a new instance of NavigatorStyle // where we set some attributes afterwards int FracInch; // minimum fractional inch to display + int viewSystemIndex; // currently selected View System (unit system) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Units"); @@ -116,6 +115,10 @@ void DlgSettingsUnitsImp::saveSettings() // Set the actual format value Base::QuantityFormat::setDefaultDenominator(FracInch); + + // Set and save the Unit System + viewSystemIndex = ui->comboBox_ViewSystem->currentIndex(); + UnitsApi::setSchema((UnitSystem)viewSystemIndex); } void DlgSettingsUnitsImp::loadSettings()