diff --git a/far/changelog b/far/changelog index e9eaadfbc5..967d3fafd4 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,8 @@ +-------------------------------------------------------------------------------- +drkns 30.07.2021 02:27:00 +0100 - build 5861 + +1. Correction of 5860. + -------------------------------------------------------------------------------- drkns 29.07.2021 23:04:52 +0100 - build 5860 diff --git a/far/common/string_utils.hpp b/far/common/string_utils.hpp index 670fcfda4b..61842d5d1e 100644 --- a/far/common/string_utils.hpp +++ b/far/common/string_utils.hpp @@ -657,4 +657,29 @@ constexpr auto make_string_view(T const Begin, T const End) noexcept return std::basic_string_view{ Size ? &*Begin : nullptr, Size }; } +class lvalue_string_view +{ +public: + lvalue_string_view() = default; + + lvalue_string_view(string_view const Str): + m_Str(Str) + { + } + + lvalue_string_view(string const& Str): + m_Str(Str) + {} + + lvalue_string_view(string&& Str) = delete; + + operator string_view() const + { + return m_Str; + } + +private: + string_view m_Str; +}; + #endif // STRING_UTILS_HPP_DE39ECEB_2377_44CB_AF4B_FA5BEA09C8C8 diff --git a/far/configdb.hpp b/far/configdb.hpp index 9ac2f00651..931d15aba8 100644 --- a/far/configdb.hpp +++ b/far/configdb.hpp @@ -44,8 +44,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Common: #include "common/bytes_view.hpp" #include "common/enumerator.hpp" -#include "common/keep_alive.hpp" #include "common/noncopyable.hpp" +#include "common/string_utils.hpp" // External: @@ -98,16 +98,14 @@ class GeneralConfig : public representable, virtual public transactional virtual void DeleteValue(string_view Key, string_view Name) = 0; - template + template [[nodiscard]] - auto ValuesEnumerator(key_type&& Key) const + auto ValuesEnumerator(lvalue_string_view const Key) const { - static_assert(std::is_convertible_v); - using value_type = std::pair; - return make_inline_enumerator([this, Key = keep_alive(FWD(Key))](const bool Reset, value_type& Value) + return make_inline_enumerator([=, this](const bool Reset, value_type& Value) { - return EnumValues(Key.get(), Reset, Value.first, Value.second); + return EnumValues(Key, Reset, Value.first, Value.second); }, [this] { @@ -451,10 +449,10 @@ class HistoryConfig: public representable, virtual public transactional }; [[nodiscard]] - auto Enumerator(unsigned int const HistoryType, string_view const HistoryName, string_view const ItemName = {}, bool const Reverse = false) + auto Enumerator(unsigned int const HistoryType, lvalue_string_view const HistoryName, lvalue_string_view const ItemName = {}, bool const Reverse = false) { using value_type = enum_data; - return make_inline_enumerator([&](const bool Reset, value_type& Value) + return make_inline_enumerator([=, this](const bool Reset, value_type& Value) { return Enum(Reset, HistoryType, HistoryName, ItemName, Value.Id, Value.Name, Value.Type, Value.Lock, Value.Time, Value.Uuid, Value.File, Value.Data, Reverse); }, diff --git a/far/keybar.cpp b/far/keybar.cpp index 8530f17309..c3d5f56a95 100644 --- a/far/keybar.cpp +++ b/far/keybar.cpp @@ -241,7 +241,9 @@ void KeyBar::SetCustomLabels(KEYBARAREA Area) CustomArea = Area; ClearKeyTitles(true); - for (const auto& [Name, Value]: ConfigProvider().GeneralCfg()->ValuesEnumerator(concat(L"KeyBarLabels."sv, strLanguage, L'.', Names[Area]))) + const auto LabelsKey = concat(L"KeyBarLabels."sv, strLanguage, L'.', Names[Area]); + + for (const auto& [Name, Value]: ConfigProvider().GeneralCfg()->ValuesEnumerator(LabelsKey)) { const auto Key = KeyNameToKey(Name); if (!Key) diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 3fb524c7bd..b272195b68 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -5860 +5861