diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp index 0ff5896ce1..db4dbda55b 100644 --- a/gnucash/gnucash-commands.cpp +++ b/gnucash/gnucash-commands.cpp @@ -361,9 +361,8 @@ Gnucash::add_quotes (const bo_str& uri) { GncQuotes quotes; std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << std::endl; - auto quote_sources = quotes.sources_as_glist(); + auto quote_sources = quotes.sources(); gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sources); - g_list_free_full (quote_sources, g_free); quotes.fetch(qof_session_get_book(session)); if (quotes.had_failures()) std::cerr << quotes.report_failures() << std::endl; diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp index 4cb4b2d3e0..c07e41f7a3 100644 --- a/gnucash/gnucash.cpp +++ b/gnucash/gnucash.cpp @@ -178,9 +178,8 @@ scm_run_gnucash (void *data, [[maybe_unused]] int argc, [[maybe_unused]] char ** gnc_update_splash_screen (checking, GNC_SPLASH_PERCENTAGE_UNKNOWN); GncQuotes quotes; auto found = (bl::format (std::string{_("Found Finance::Quote version {1}.")}) % quotes.version()).str(); - auto quote_sources = quotes.sources_as_glist(); + auto quote_sources = quotes.sources(); gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sources); - g_list_free_full (quote_sources, g_free); gnc_update_splash_screen (found.c_str(), GNC_SPLASH_PERCENTAGE_UNKNOWN); } catch (const GncQuoteException& err) diff --git a/libgnucash/app-utils/test/gtest-gnc-quotes.cpp b/libgnucash/app-utils/test/gtest-gnc-quotes.cpp index 9d146d0bc4..fc719bfad3 100644 --- a/libgnucash/app-utils/test/gtest-gnc-quotes.cpp +++ b/libgnucash/app-utils/test/gtest-gnc-quotes.cpp @@ -127,9 +127,8 @@ protected: gnc_commodity_set_quote_source(fkcm, source); gnc_commodity_commit_edit(fkcm); gnc_commodity_table_insert(comm_table, fkcm); - GList *sources = g_list_prepend(nullptr, (void*)"alphavantage"); + std::vector sources = {"alphavantage"}; gnc_quote_source_set_fq_installed("TestSuite", sources); - g_list_free(sources); } ~GncQuotesTest() { gnc_clear_current_session(); diff --git a/libgnucash/engine/gnc-commodity.cpp b/libgnucash/engine/gnc-commodity.cpp index f092703f82..f230355d3c 100644 --- a/libgnucash/engine/gnc-commodity.cpp +++ b/libgnucash/engine/gnc-commodity.cpp @@ -35,6 +35,7 @@ #include #include +#include "gnc-commodity.hpp" #include "gnc-commodity.h" #include "gnc-locale-utils.h" #include "gnc-prefs.h" @@ -537,15 +538,11 @@ gnc_quote_source_get_internal_name (const gnc_quote_source *source) ********************************************************************/ void gnc_quote_source_set_fq_installed (const char* version_string, - const GList *sources_list) + const std::vector& sources_list) { - gnc_quote_source *source; - char *source_name; - const GList *node; - ENTER(" "); - if (!sources_list) + if (sources_list.empty()) return; if (version_string) @@ -553,11 +550,11 @@ gnc_quote_source_set_fq_installed (const char* version_string, else fq_version.clear(); - for (node = sources_list; node; node = node->next) + for (const auto& source_name_str : sources_list) { - source_name = static_cast(node->data); + auto source_name = source_name_str.c_str(); + auto source = gnc_quote_source_lookup_by_internal(source_name); - source = gnc_quote_source_lookup_by_internal(source_name); if (source != NULL) { DEBUG("Found source %s: %s", source_name, source->user_name); diff --git a/libgnucash/engine/gnc-commodity.h b/libgnucash/engine/gnc-commodity.h index 75d0bc693b..9fde3220da 100644 --- a/libgnucash/engine/gnc-commodity.h +++ b/libgnucash/engine/gnc-commodity.h @@ -158,18 +158,6 @@ gboolean gnc_quote_source_fq_installed (void); */ const char* gnc_quote_source_fq_version (void); -/** Update gnucash internal tables based on what Finance::Quote - * sources are installed. Sources that have been explicitly coded - * into gnucash are marked sensitive/insensitive based upon whether - * they are present. New sources that gnucash doesn't know about are - * added to its internal tables. - * - * @param sources_list A list of strings containing the source names - * as they are known to F::Q. - */ -void gnc_quote_source_set_fq_installed (const char* version_string, - const GList *sources_list); - /** Return the number of entries for a given type of quote source. * * @param type The quote source type whose count should be returned. diff --git a/libgnucash/engine/gnc-commodity.hpp b/libgnucash/engine/gnc-commodity.hpp index b1e0c53cc7..223d9abe72 100644 --- a/libgnucash/engine/gnc-commodity.hpp +++ b/libgnucash/engine/gnc-commodity.hpp @@ -39,6 +39,18 @@ using CommVec = std::vector; +/** Update gnucash internal tables based on what Finance::Quote + * sources are installed. Sources that have been explicitly coded + * into gnucash are marked sensitive/insensitive based upon whether + * they are present. New sources that gnucash doesn't know about are + * added to its internal tables. + * + * @param sources_list A list of strings containing the source names + * as they are known to F::Q. + */ +void gnc_quote_source_set_fq_installed (const char* version_string, + const std::vector& sources_list); + #endif /* GNC_COMMODITY_HPP */ /** @} */ /** @} */