Drop the single quotes instance code for now

I have been reading on singleton implementations and there appears
to be a lot of pushback against those.
We can revisit this if it turns out performance degrades
significantly by running the F::Q check multiple times.
This commit is contained in:
Geert Janssens 2021-02-11 15:20:21 +01:00 committed by John Ralls
parent 616a672d52
commit 6ce91d7f49
5 changed files with 3 additions and 23 deletions

View File

@ -131,7 +131,7 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
{
if (*m_quotes_cmd == "info")
{
auto quotes = gnc_get_quotes_instance();
GncQuotes quotes;
if (quotes.cmd_result() == 0)
{
std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << "\n";

View File

@ -82,7 +82,7 @@ scm_add_quotes(void *data, [[maybe_unused]] int argc, [[maybe_unused]] char **ar
gnc_prefs_init ();
qof_event_suspend();
auto quotes = gnc_get_quotes_instance();
GncQuotes quotes;
if (quotes.cmd_result() == 0)
{
std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << std::endl;

View File

@ -176,7 +176,7 @@ scm_run_gnucash (void *data, [[maybe_unused]] int argc, [[maybe_unused]] char **
/* Install Price Quote Sources */
auto msg = bl::translate ("Checking Finance::Quote...").str(gnc_get_boost_locale());
auto quotes = gnc_get_quotes_instance();
GncQuotes quotes;
if (quotes.cmd_result() == 0)
{
msg = (bl::format (bl::translate("Found Finance::Quote version {1}.")) % quotes.version()).str(gnc_get_boost_locale());

View File

@ -51,8 +51,6 @@ namespace bp = boost::process;
namespace bpt = boost::property_tree;
namespace bio = boost::iostreams;
static GncQuotes quotes_cached;
static bool quotes_initialized = false;
CommVec
gnc_quotes_get_quotable_commodities(const gnc_commodity_table * table);
@ -256,19 +254,3 @@ gnc_quotes_get_quotable_commodities (const gnc_commodity_table * table)
//LEAVE ("list head %p", &l);
return l;
}
const GncQuotes& gnc_get_quotes_instance()
{
// The GncQuotes constructor runs check to test if Finance::Quote is properly installed
// However due to a race condition the instantiation of the static quotes_cached
// may or may not happen before binreloc has run. If binreloc didn't run, this will
// try to run gnc-fq-check from the hard-coded install dir. This will fail in all
// cases where binreloc is relevant (Windows, macOS or run from builddir).
// To catch this, explicitly reinstantiate quotes_cached at first use.
if (!quotes_initialized)
{
quotes_cached = GncQuotes();
quotes_initialized = true;
}
return quotes_cached;
}

View File

@ -60,6 +60,4 @@ private:
std::string m_error_msg;
};
const GncQuotes& gnc_get_quotes_instance (void);
#endif /* GNC_QUOTES_HPP */