diff --git a/libgnucash/engine/qofbook.cpp b/libgnucash/engine/qofbook.cpp index ab2b012319..1cbc673eb8 100644 --- a/libgnucash/engine/qofbook.cpp +++ b/libgnucash/engine/qofbook.cpp @@ -1255,6 +1255,27 @@ qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr) } } + +void +qof_book_unset_feature (QofBook *book, const gchar *key, const gchar *descr) +{ + KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book)); + KvpValue* feature = nullptr; + auto feature_slot = frame->get_slot({GNC_FEATURES}); + if (feature_slot) + { + auto feature_frame = feature_slot->get(); + feature = feature_frame->get_slot({key}); + } + if (feature == nullptr || g_strcmp0 (feature->get(), descr)) + { + qof_book_begin_edit (book); + delete frame->set_path({GNC_FEATURES, key}, nullptr); + qof_instance_set_dirty (QOF_INSTANCE (book)); + qof_book_commit_edit (book); + } +} + void qof_book_load_options (QofBook *book, GNCOptionLoad load_cb, GNCOptionDB *odb) { diff --git a/libgnucash/engine/qofbook.h b/libgnucash/engine/qofbook.h index f48ed94002..a262299380 100644 --- a/libgnucash/engine/qofbook.h +++ b/libgnucash/engine/qofbook.h @@ -382,6 +382,7 @@ void qof_book_option_frame_delete (QofBook *book, const char* opt_name); /** Access functions for reading and setting the used-features on this book. */ GHashTable *qof_book_get_features (QofBook *book); +void qof_book_unset_feature (QofBook *book, const gchar *key, const gchar *descr); void qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr); void qof_book_begin_edit(QofBook *book);