From 884e6b7415c562621487abe922fd3042da71ff32 Mon Sep 17 00:00:00 2001 From: Tim Stack Date: Mon, 1 Apr 2024 10:43:45 -0700 Subject: [PATCH] [help_text] fix static init issue --- src/help_text.cc | 10 +++++++++- src/help_text.hh | 2 +- src/help_text_formatter.cc | 4 +--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/help_text.cc b/src/help_text.cc index 46113150..a056ed19 100644 --- a/src/help_text.cc +++ b/src/help_text.cc @@ -104,10 +104,18 @@ help_text::with_prql_path( return *this; } +std::multimap& +help_text::tag_map() +{ + static std::multimap retval; + + return retval; +} + void help_text::index_tags() { for (const auto& tag : this->ht_tags) { - TAGGED.insert(std::make_pair(tag, this)); + tag_map().insert(std::make_pair(tag, this)); } } diff --git a/src/help_text.hh b/src/help_text.hh index 5402dfc2..7b38ec2f 100644 --- a/src/help_text.hh +++ b/src/help_text.hh @@ -250,7 +250,7 @@ struct help_text { void index_tags(); - static std::multimap TAGGED; + static std::multimap& tag_map(); }; #endif diff --git a/src/help_text_formatter.cc b/src/help_text_formatter.cc index 64dc3f17..5d3b8a21 100644 --- a/src/help_text_formatter.cc +++ b/src/help_text_formatter.cc @@ -42,15 +42,13 @@ using namespace lnav::roles::literals; -std::multimap help_text::TAGGED; - static std::vector get_related(const help_text& ht) { std::vector retval; for (const auto& tag : ht.ht_tags) { - auto tagged = help_text::TAGGED.equal_range(tag); + auto tagged = help_text::tag_map().equal_range(tag); for (auto tag_iter = tagged.first; tag_iter != tagged.second; ++tag_iter)