From 1516bb18b070d6fbc0388791edb8cb1040ad0d6e Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 2 Dec 2021 22:12:29 +0800 Subject: [PATCH] [gnc-features.cpp] backport gnc_features_set_unused from master --- libgnucash/engine/gnc-features.cpp | 17 +++++++++++++++++ libgnucash/engine/gnc-features.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/libgnucash/engine/gnc-features.cpp b/libgnucash/engine/gnc-features.cpp index 5e2823a3c3..07d3e59fe2 100644 --- a/libgnucash/engine/gnc-features.cpp +++ b/libgnucash/engine/gnc-features.cpp @@ -91,6 +91,23 @@ void gnc_features_set_used (QofBook *book, const gchar *feature) qof_book_set_feature (book, feature, iter->second.c_str()); } + +void gnc_features_set_unused (QofBook *book, const gchar *feature) +{ + g_return_if_fail (book); + g_return_if_fail (feature); + + /* Can't set an unknown feature */ + auto iter = features_table.find (feature); + if (iter == features_table.end ()) + { + PWARN("Tried to set unknown feature as unused."); + return; + } + + qof_book_unset_feature (book, feature); +} + gboolean gnc_features_check_used (QofBook *book, const gchar * feature) { return qof_book_test_feature (book, feature); diff --git a/libgnucash/engine/gnc-features.h b/libgnucash/engine/gnc-features.h index 030c02531e..b5960ac7ad 100644 --- a/libgnucash/engine/gnc-features.h +++ b/libgnucash/engine/gnc-features.h @@ -67,6 +67,13 @@ extern "C" { */ gchar *gnc_features_test_unknown (QofBook *book); +/** + * Indicate that the current book does not use the given feature. This + * will allow older versions of GnuCash that don't support this + * feature to load this book. + */ +void gnc_features_set_unused (QofBook *book, const gchar *feature); + /** * Indicate that the current book uses the given feature. This will prevent * older versions of GnuCash that don't support this feature to refuse to load