Bug 798812 - crashes after I open a customer report and select…

Edit/Report Options

As a result of auto instead of auto& in a std::visit call which
resulted in a temporary option whose GncOwner* was destroyed before
we could use it.
This commit is contained in:
John Ralls 2023-04-15 13:21:47 -07:00
parent 96c8cb738c
commit f4f481fe38

View File

@ -47,7 +47,7 @@ template <typename ValueType> ValueType
GncOption::get_value() const GncOption::get_value() const
{ {
return std::visit( return std::visit(
[](const auto option)->ValueType { [](const auto& option)->ValueType {
if constexpr (is_same_decayed_v<decltype(option.get_value()), if constexpr (is_same_decayed_v<decltype(option.get_value()),
ValueType>) ValueType>)
return option.get_value(); return option.get_value();
@ -80,7 +80,7 @@ template <typename ValueType> ValueType
GncOption::get_default_value() const GncOption::get_default_value() const
{ {
return std::visit( return std::visit(
[](const auto option)->ValueType { [](const auto& option)->ValueType {
if constexpr (is_same_decayed_v<decltype(option.get_value()), if constexpr (is_same_decayed_v<decltype(option.get_value()),
ValueType>) ValueType>)
return option.get_default_value(); return option.get_default_value();