changed unitAbbreviation_ over to not use pointers

This commit is contained in:
AdenKoperczak 2024-07-26 11:42:48 -04:00
parent 54748ce812
commit 801125d87a

View file

@ -56,7 +56,7 @@ public:
std::function<T(const std::string&)> mapToValue_ {nullptr};
double unitScale_ {1};
const std::string * unitAbbreviation_ {nullptr};
std::optional<std::string> unitAbbreviation_ {};
bool unitEnabled_ {false};
};
@ -484,7 +484,7 @@ void SettingsInterface<T>::SetUnit(const double& scale,
const std::string& abbreviation)
{
p->unitScale_ = scale;
p->unitAbbreviation_ = &abbreviation;
p->unitAbbreviation_ = abbreviation;
p->unitEnabled_ = true;
p->UpdateEditWidget();
p->UpdateUnitLabel();
@ -604,7 +604,7 @@ void SettingsInterface<T>::Impl::UpdateUnitLabel()
return;
}
unitLabel_->setText(QString::fromStdString(*unitAbbreviation_));
unitLabel_->setText(QString::fromStdString(unitAbbreviation_.value_or("")));
}
template<class T>