Prevent older gnucash versions from opening a data file if previously unhandled kvps are used

Prior to gnucash 26.4 with kvps for address, entry, job and taxtable objects
were not handled properly (but not in use either).
This patch will prevent any older version of gnucash to open a data file if a newer
version has written any of the above kvps.

A follow up on bug 728841
This commit is contained in:
Geert Janssens 2014-04-24 12:11:14 +02:00
parent f0e42a005f
commit 171ac3de90
6 changed files with 24 additions and 0 deletions

View File

@ -43,6 +43,7 @@ static gncFeature known_features[] =
{
{ GNC_FEATURE_CREDIT_NOTES, "Customer and vendor credit notes (requires at least GnuCash 2.5.0)" },
{ GNC_FEATURE_NUM_FIELD_SOURCE, "User specifies source of 'num' field'; either transaction number or split action (requires at least GnuCash 2.5.0)" },
{ GNC_FEATURE_KVP_EXTRA_DATA, "Extra data for addresses, jobs or invoice entries (requires at least GnuCash 2.6.4)" },
{ NULL },
};

View File

@ -36,11 +36,14 @@
#ifndef GNC_FEATURES_H
#define GNC_FEATURES_H
#include "libqof/qof/qof.h"
/** @name Defined features
@{
*/
#define GNC_FEATURE_CREDIT_NOTES "Credit Notes"
#define GNC_FEATURE_NUM_FIELD_SOURCE "Number Field Source"
#define GNC_FEATURE_KVP_EXTRA_DATA "Extra data in addresses, jobs or invoice entries"
/** @} */

View File

@ -32,6 +32,7 @@
#include "gncAddress.h"
#include "gncAddressP.h"
#include "gncCustomerP.h"
#include "gnc-features.h"
struct _gncAddress
{
@ -492,6 +493,10 @@ static void address_free (QofInstance *inst)
void gncAddressCommitEdit (GncAddress *addr)
{
/* GnuCash 2.6.3 and earlier didn't handle address kvp's... */
if (!kvp_frame_is_empty (addr->inst.kvp_data))
gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (addr)), GNC_FEATURE_KVP_EXTRA_DATA);
if (!qof_commit_edit (QOF_INSTANCE(addr))) return;
qof_commit_edit_part2 (&addr->inst, gncAddressOnError,
gncAddressOnDone, address_free);

View File

@ -33,6 +33,7 @@
#include "gncEntry.h"
#include "gncEntryP.h"
#include "gnc-features.h"
#include "gncInvoice.h"
#include "gncOrder.h"
@ -1505,6 +1506,10 @@ static void entry_free (QofInstance *inst)
void gncEntryCommitEdit (GncEntry *entry)
{
/* GnuCash 2.6.3 and earlier didn't handle entry kvp's... */
if (!kvp_frame_is_empty (entry->inst.kvp_data))
gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (entry)), GNC_FEATURE_KVP_EXTRA_DATA);
if (!qof_commit_edit (QOF_INSTANCE(entry))) return;
qof_commit_edit_part2 (&entry->inst, gncEntryOnError,
gncEntryOnDone, entry_free);

View File

@ -31,6 +31,7 @@
#include <glib.h>
#include <string.h>
#include "gnc-features.h"
#include "gncInvoice.h"
#include "gncJob.h"
#include "gncJobP.h"
@ -366,6 +367,10 @@ static void gncJobOnDone (QofInstance *qof) { }
void gncJobCommitEdit (GncJob *job)
{
/* GnuCash 2.6.3 and earlier didn't handle job kvp's... */
if (!kvp_frame_is_empty (job->inst.kvp_data))
gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (job)), GNC_FEATURE_KVP_EXTRA_DATA);
if (!qof_commit_edit (QOF_INSTANCE(job))) return;
qof_commit_edit_part2 (&job->inst, gncJobOnError,
gncJobOnDone, job_free);

View File

@ -30,6 +30,7 @@
#include <glib.h>
#include "gnc-features.h"
#include "gncTaxTableP.h"
struct _gncTaxTable
@ -649,6 +650,10 @@ static void table_free (QofInstance *inst)
void gncTaxTableCommitEdit (GncTaxTable *table)
{
/* GnuCash 2.6.3 and earlier didn't handle taxtable kvp's... */
if (!kvp_frame_is_empty (table->inst.kvp_data))
gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (table)), GNC_FEATURE_KVP_EXTRA_DATA);
if (!qof_commit_edit (QOF_INSTANCE(table))) return;
qof_commit_edit_part2 (&table->inst, gncTaxTableOnError,
gncTaxTableOnDone, table_free);