mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Revert some qof_instance_get_guid() calls to qof_entity_get_guid().
Those two functions were merged into one, qof_instance_get_guid(), in r15773, but they returned different values if the parameter was NULL. Some code depends on the return value being guid_null(), or maybe even NULL, so revert the changes entity->instance, where the entity is not guaranteed to be non-NULL. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16212 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
fa28f0e4f0
commit
dcfda18f7c
@ -709,6 +709,7 @@ reference_list_lookup(gpointer data, gpointer user_data)
|
||||
ref_param = (QofParam*)data;
|
||||
object_node = params->output_node;
|
||||
ent = params->qsf_ent;
|
||||
g_return_if_fail(ent);
|
||||
ns = params->qsf_ns;
|
||||
starter = g_new(QofInstanceReference, 1);
|
||||
starter->ent_guid = qof_instance_get_guid(ent);
|
||||
@ -766,6 +767,7 @@ qsf_entity_foreach(QofInstance *ent, gpointer data)
|
||||
const GUID *cm_guid;
|
||||
gchar cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
|
||||
g_return_if_fail(ent != NULL);
|
||||
g_return_if_fail(data != NULL);
|
||||
params = (qsf_param*)data;
|
||||
param_count = ++params->count;
|
||||
|
@ -418,7 +418,7 @@ qof_book_get_counter (QofBook *book, const char *counter_name)
|
||||
gboolean qof_book_register (void)
|
||||
{
|
||||
static QofParam params[] = {
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
|
||||
{ QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL },
|
||||
{ NULL },
|
||||
};
|
||||
|
@ -267,7 +267,7 @@ gboolean qof_book_equal (const QofBook *book_1, const QofBook *book_2);
|
||||
gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
|
||||
|
||||
/** deprecated */
|
||||
#define qof_book_get_guid(X) qof_instance_get_guid (QOF_INSTANCE(X))
|
||||
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))
|
||||
|
||||
#endif /* QOF_BOOK_H */
|
||||
/** @} */
|
||||
|
@ -702,6 +702,7 @@ qof_book_merge_commit_rule_loop(QofBookMergeData *mergeData,
|
||||
g_return_if_fail(rule != NULL);
|
||||
g_return_if_fail(mergeData != NULL);
|
||||
g_return_if_fail(mergeData->targetBook != NULL);
|
||||
g_return_if_fail(rule->importEnt && rule->targetEnt);
|
||||
g_return_if_fail((rule->mergeResult != MERGE_NEW)||(rule->mergeResult != MERGE_UPDATE));
|
||||
|
||||
DEBUG ("qof_book_merge_commit_rule_loop rule: type: %s, result: %s, importEnt Type: %s, guid: %s",
|
||||
|
@ -465,6 +465,12 @@ qof_instance_get_guid (gconstpointer inst)
|
||||
return &(priv->guid);
|
||||
}
|
||||
|
||||
const GUID *
|
||||
qof_entity_get_guid (gconstpointer ent)
|
||||
{
|
||||
return ent ? qof_instance_get_guid(ent) : guid_null();
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_set_guid (gpointer ptr, const GUID *guid)
|
||||
{
|
||||
|
@ -101,6 +101,10 @@ gboolean qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2);
|
||||
/** Return the GUID of this instance */
|
||||
const GUID * qof_instance_get_guid (gconstpointer);
|
||||
|
||||
/** \deprecated Use qof_instance_get_guid instead.
|
||||
* Works like qof_instance_get_guid, but returns NULL on NULL */
|
||||
const GUID * qof_entity_get_guid (gconstpointer);
|
||||
|
||||
/** Return the collection this instance belongs to */
|
||||
QofCollection* qof_instance_get_collection (gconstpointer inst);
|
||||
|
||||
|
@ -1275,7 +1275,7 @@ void qof_query_set_book (QofQuery *q, QofBook *book)
|
||||
slist = g_slist_prepend (slist, QOF_PARAM_GUID);
|
||||
slist = g_slist_prepend (slist, QOF_PARAM_BOOK);
|
||||
qof_query_add_guid_match (q, slist,
|
||||
qof_book_get_guid(book), QOF_QUERY_AND);
|
||||
qof_instance_get_guid(book), QOF_QUERY_AND);
|
||||
}
|
||||
|
||||
GList * qof_query_get_books (QofQuery *q)
|
||||
|
@ -1455,8 +1455,7 @@ query_collect_cb(QofInstance* ent, gpointer user_data)
|
||||
query_coll_t pdata;
|
||||
GUID *guid;
|
||||
|
||||
guid = guid_malloc();
|
||||
guid = (GUID*)qof_instance_get_guid(ent);
|
||||
guid = (GUID*)qof_entity_get_guid(ent);
|
||||
pdata = (query_coll_t)user_data;
|
||||
pdata->guids = g_list_append(pdata->guids, guid);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ entity_set_reference_cb(QofInstance *ent, gpointer user_data)
|
||||
QofBook *partial_book;
|
||||
|
||||
partial_book = (QofBook*)user_data;
|
||||
g_return_if_fail(partial_book || ent);
|
||||
g_return_if_fail(partial_book && ent);
|
||||
reference = NULL;
|
||||
coll = NULL;
|
||||
book_ref_list = qof_book_get_data(partial_book, ENTITYREFERENCE);
|
||||
@ -122,6 +122,7 @@ create_reference(QofInstance *ent, const QofParam *param)
|
||||
char cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
gchar *cm_string;
|
||||
|
||||
g_return_val_if_fail(ent, NULL);
|
||||
ref_ent = QOF_INSTANCE(param->param_getfcn(ent, param));
|
||||
if(!ref_ent) { return NULL; }
|
||||
reference = g_new0(QofInstanceReference, 1);
|
||||
|
@ -368,15 +368,17 @@ col_ref_cb (QofInstance* ref_ent, gpointer user_data)
|
||||
char cm_sa[GUID_ENCODING_LENGTH + 1];
|
||||
gchar *cm_string;
|
||||
|
||||
g_return_if_fail(user_data);
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
ent = qecd->from;
|
||||
g_return_if_fail(ent);
|
||||
ref = g_new0(QofInstanceReference, 1);
|
||||
ref->type = ent->e_type;
|
||||
ref->ref_guid = g_new(GUID, 1);
|
||||
ref->ent_guid = qof_instance_get_guid(ent);
|
||||
ref->param = qof_class_get_parameter(ent->e_type,
|
||||
qecd->param->param_name);
|
||||
cm_guid = qof_instance_get_guid(ref_ent);
|
||||
cm_guid = qof_entity_get_guid(ref_ent);
|
||||
guid_to_string_buff(cm_guid, cm_sa);
|
||||
cm_string = g_strdup(cm_sa);
|
||||
if(TRUE == string_to_guid(cm_string, ref->ref_guid)) {
|
||||
@ -594,7 +596,8 @@ qof_instance_coll_foreach(QofInstance *original, gpointer user_data)
|
||||
QofBook *targetBook;
|
||||
QofCollection *coll;
|
||||
QofInstance *copy;
|
||||
|
||||
|
||||
g_return_if_fail(original != NULL);
|
||||
g_return_if_fail(user_data != NULL);
|
||||
copy = NULL;
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
@ -612,7 +615,8 @@ qof_instance_coll_copy(QofInstance *original, gpointer user_data)
|
||||
QofBook *book;
|
||||
QofInstance *inst;
|
||||
const GUID *g;
|
||||
|
||||
|
||||
g_return_if_fail(original != NULL);
|
||||
g_return_if_fail(user_data != NULL);
|
||||
qecd = (QofInstanceCopyData*)user_data;
|
||||
book = qof_session_get_book(qecd->new_session);
|
||||
|
@ -258,7 +258,7 @@ gnc_cm_event_handler (QofInstance *entity,
|
||||
gpointer user_data,
|
||||
gpointer event_data)
|
||||
{
|
||||
const GUID *guid = qof_instance_get_guid(entity);
|
||||
const GUID *guid = qof_entity_get_guid(entity);
|
||||
#if CM_DEBUG
|
||||
fprintf (stderr, "event_handler: event %d, entity %p, guid %s\n", event_type,
|
||||
entity, guid);
|
||||
|
@ -208,7 +208,7 @@ get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
for (node=blist; node; node=node->next)
|
||||
{
|
||||
book = node->data;
|
||||
if (guid_equal (qof_instance_get_guid(QOF_INSTANCE(book)), &guid)) break;
|
||||
if (guid_equal (qof_entity_get_guid(QOF_INSTANCE(book)), &guid)) break;
|
||||
book = NULL;
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ int finishQuery(PGBackend *be);
|
||||
for (node=be->blist; node; node=node->next) \
|
||||
{ \
|
||||
book = node->data; \
|
||||
if (guid_equal (qof_instance_get_guid((QofInstance*)book), &book_guid)) break; \
|
||||
if (guid_equal (qof_entity_get_guid((QofInstance*)book), &book_guid)) break; \
|
||||
book = NULL; \
|
||||
} \
|
||||
if (!book) return data; \
|
||||
|
@ -13,7 +13,7 @@ define(`account', `gncAccount, Account, Account, a,
|
||||
commodity, , char *, gnc_commodity_get_unique_name(xaccAccountGetCommodity(ptr)),
|
||||
version, , int32, qof_instance_get_version(ptr),
|
||||
iguid, , int32, qof_instance_get_idata(ptr),
|
||||
bookGUID, , GUID *, qof_instance_get_guid((QofInstance*)gnc_account_get_book(ptr)),
|
||||
bookGUID, , GUID *, qof_entity_get_guid((QofInstance*)gnc_account_get_book(ptr)),
|
||||
parentGUID, , GUID *, xaccAccountGetGUID(gnc_account_get_parent(ptr)),
|
||||
accountGUID, KEY, GUID *, xaccAccountGetGUID(ptr),
|
||||
')
|
||||
@ -362,7 +362,7 @@ define(`compare_version',
|
||||
|
||||
p = be->buff; *p = 0;
|
||||
p = stpcpy (p, "SELECT version FROM tablename($@) WHERE key_fieldname($@) = ''`");
|
||||
p = guid_to_string_buff (qof_instance_get_guid(QOF_INSTANCE(ptr)), p);
|
||||
p = guid_to_string_buff (qof_entity_get_guid(QOF_INSTANCE(ptr)), p);
|
||||
p = stpcpy (p, "''`;");
|
||||
SEND_QUERY (be,be->buff, -1);
|
||||
sql_version = GPOINTER_TO_INT(pgendGetResults (be, get_version_cb, (gpointer) -1));
|
||||
@ -392,7 +392,7 @@ define(`is_deleted',
|
||||
|
||||
p = be->buff; *p = 0;
|
||||
p = stpcpy (p, "SELECT version FROM tablename($@)" "Trail WHERE key_fieldname($@) = ''`");
|
||||
p = guid_to_string_buff (qof_instance_get_guid(QOF_INSTANCE(ptr)), p);
|
||||
p = guid_to_string_buff (qof_entity_get_guid(QOF_INSTANCE(ptr)), p);
|
||||
p = stpcpy (p, "''` AND change = ''`d''`;");
|
||||
SEND_QUERY (be,be->buff, -1);
|
||||
sql_version = GPOINTER_TO_INT(pgendGetResults (be, get_version_cb, (gpointer) -1));
|
||||
|
@ -114,9 +114,9 @@ gboolean gncEmployeeIsDirty (GncEmployee *employee);
|
||||
#define EMPLOYEE_CC "credit_card_account"
|
||||
|
||||
/** deprecated routines */
|
||||
#define gncEmployeeGetGUID(E) qof_instance_get_guid(QOF_INSTANCE(E))
|
||||
#define gncEmployeeGetGUID(E) qof_entity_get_guid(QOF_INSTANCE(E))
|
||||
#define gncEmployeeGetBook(E) qof_instance_get_book(QOF_INSTANCE(E))
|
||||
#define gncEmployeeRetGUID(E) (E ? *(qof_instance_get_guid(QOF_INSTANCE(E))) : *(guid_null()))
|
||||
#define gncEmployeeRetGUID(E) (E ? *(qof_entity_get_guid(QOF_INSTANCE(E))) : *(guid_null()))
|
||||
#define gncEmployeeLookupDirect(G,B) gncEmployeeLookup((B),&(G))
|
||||
|
||||
#endif /* GNC_EMPLOYEE_H_ */
|
||||
|
@ -232,8 +232,8 @@ Account *gnc_book_get_root_account(QofBook *book);
|
||||
void gnc_book_set_root_account(QofBook *book, Account *root);
|
||||
|
||||
/** @deprecated */
|
||||
#define xaccAccountGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
#define xaccAccountReturnGUID(X) (X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
#define xaccAccountGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
||||
#define xaccAccountReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
|
||||
/** The xaccAccountLookup() subroutine will return the
|
||||
* account associated with the given id, or NULL
|
||||
|
@ -318,7 +318,7 @@ gboolean SXRegister (void);
|
||||
/** \deprecated */
|
||||
#define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
|
||||
/** \deprecated */
|
||||
#define xaccSchedXactionGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
#define xaccSchedXactionGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
||||
/** \deprecated */
|
||||
#define xaccSchedXactionGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X))
|
||||
|
||||
|
@ -1814,7 +1814,7 @@ gboolean xaccSplitRegister (void)
|
||||
{ "d-share-amount", QOF_TYPE_DOUBLE,
|
||||
(QofAccessFunc)DxaccSplitGetShareAmount, NULL },
|
||||
{ "d-share-int64", QOF_TYPE_INT64,
|
||||
(QofAccessFunc)qof_instance_get_guid, NULL },
|
||||
(QofAccessFunc)qof_entity_get_guid, NULL },
|
||||
{ SPLIT_BALANCE, QOF_TYPE_NUMERIC,
|
||||
(QofAccessFunc)xaccSplitGetBalance, NULL },
|
||||
{ SPLIT_CLEARED_BALANCE, QOF_TYPE_NUMERIC,
|
||||
@ -1855,7 +1855,7 @@ gboolean xaccSplitRegister (void)
|
||||
{ SPLIT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccSplitGetSlots, NULL },
|
||||
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, NULL },
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID,
|
||||
(QofAccessFunc)qof_instance_get_guid, NULL },
|
||||
(QofAccessFunc)qof_entity_get_guid, NULL },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
@ -500,9 +500,9 @@ gnc_numeric xaccSplitVoidFormerValue(const Split *split);
|
||||
/** @} */
|
||||
|
||||
/** \deprecated */
|
||||
#define xaccSplitGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
#define xaccSplitGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
||||
/** \deprecated */
|
||||
#define xaccSplitReturnGUID(X) (X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
#define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
|
||||
#endif /* XACC_SPLIT_H */
|
||||
/** @} */
|
||||
|
@ -1971,7 +1971,7 @@ gboolean xaccTransRegister (void)
|
||||
{ QOF_PARAM_BOOK, QOF_ID_BOOK,
|
||||
(QofAccessFunc)qof_instance_get_book, NULL },
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID,
|
||||
(QofAccessFunc)qof_instance_get_guid, NULL },
|
||||
(QofAccessFunc)qof_entity_get_guid, NULL },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
@ -567,9 +567,9 @@ Timespec xaccTransGetVoidTime(const Transaction *tr);
|
||||
/** \deprecated */
|
||||
#define xaccTransGetBook(X) qof_instance_get_book (QOF_INSTANCE(X))
|
||||
/** \deprecated */
|
||||
#define xaccTransGetGUID(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
#define xaccTransGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
||||
/** \deprecated */
|
||||
#define xaccTransReturnGUID(X) (X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
#define xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
/** \deprecated */
|
||||
#define xaccTransGetSlots(X) qof_instance_get_slots (QOF_INSTANCE(X))
|
||||
|
||||
|
@ -105,7 +105,7 @@ void gnc_budget_commit_edit(GncBudget *bgt);
|
||||
|
||||
const GUID* gnc_budget_get_guid(GncBudget* budget);
|
||||
#define gnc_budget_return_guid(X) \
|
||||
(X ? *(qof_instance_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
(X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
|
||||
|
||||
/** Set/Get the name of the Budget */
|
||||
void gnc_budget_set_name(GncBudget* budget, const gchar* name);
|
||||
|
@ -440,7 +440,7 @@ gboolean gnc_lot_register (void)
|
||||
(QofAccessFunc) gnc_lot_get_notes,
|
||||
(QofSetterFunc) gnc_lot_set_notes },
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID,
|
||||
(QofAccessFunc) qof_instance_get_guid, NULL },
|
||||
(QofAccessFunc) qof_entity_get_guid, NULL },
|
||||
{ QOF_PARAM_BOOK, QOF_ID_BOOK,
|
||||
(QofAccessFunc) gnc_lot_get_book, NULL },
|
||||
{ LOT_IS_CLOSED, QOF_TYPE_BOOLEAN,
|
||||
|
@ -156,7 +156,7 @@ void gnc_lot_set_notes (GNCLot *, const char *);
|
||||
* */
|
||||
KvpFrame * gnc_lot_get_slots (const GNCLot *);
|
||||
|
||||
#define gnc_lot_get_guid(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
#define gnc_lot_get_guid(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
||||
|
||||
#define LOT_IS_CLOSED "is-closed?"
|
||||
#define LOT_BALANCE "balance"
|
||||
|
@ -227,8 +227,8 @@ const char * gnc_price_get_typestr(const GNCPrice *p);
|
||||
gnc_numeric gnc_price_get_value(const GNCPrice *p);
|
||||
gboolean gnc_price_equal(const GNCPrice *p1, const GNCPrice *p2);
|
||||
|
||||
#define gnc_price_get_guid(X) qof_instance_get_guid(QOF_INSTANCE(X))
|
||||
#define gnc_price_return_guid(X) (*(qof_instance_get_guid(QOF_INSTANCE(X))))
|
||||
#define gnc_price_get_guid(X) qof_entity_get_guid(QOF_INSTANCE(X))
|
||||
#define gnc_price_return_guid(X) (*(qof_entity_get_guid(QOF_INSTANCE(X))))
|
||||
#define gnc_price_get_book(X) qof_instance_get_book(QOF_INSTANCE(X))
|
||||
/** @} */
|
||||
|
||||
|
@ -75,7 +75,7 @@ chart_collection_cb(QofInstance *ent, gpointer user_data)
|
||||
{
|
||||
success = qof_instance_copy_to_session(data->chart_session, ent);
|
||||
if(!success) { return; }
|
||||
guid = qof_instance_get_guid(ent);
|
||||
guid = qof_entity_get_guid(ent);
|
||||
book = qof_session_get_book(data->chart_session);
|
||||
copy_coll = qof_book_get_collection(book, GNC_ID_ACCOUNT);
|
||||
data->equity_account = (Account*)qof_collection_lookup_entity(copy_coll, guid);
|
||||
@ -119,7 +119,7 @@ chart_entity_cb(QofInstance *ent, gpointer user_data)
|
||||
data = (chart_data*)user_data;
|
||||
trans_time = data->chart_time_t;
|
||||
data->param_ref_list = NULL;
|
||||
guid = qof_instance_get_guid(ent);
|
||||
guid = qof_entity_get_guid(ent);
|
||||
acc_ent = (Account*)ent;
|
||||
ref = NULL;
|
||||
equity_account = data->equity_account;
|
||||
|
@ -230,7 +230,7 @@ gnc_restore_all_state (gpointer session, gpointer unused)
|
||||
|
||||
/* Get the book GUID */
|
||||
book = qof_session_get_book(session);
|
||||
guid = qof_instance_get_guid(QOF_INSTANCE(book));
|
||||
guid = qof_entity_get_guid(QOF_INSTANCE(book));
|
||||
guid_string = guid_to_string(guid);
|
||||
|
||||
keyfile = gnc_find_state_file(url, guid_string, &filename);
|
||||
@ -317,7 +317,7 @@ gnc_save_all_state (gpointer session, gpointer unused)
|
||||
|
||||
/* Get the book GUID */
|
||||
book = qof_session_get_book(session);
|
||||
guid = qof_instance_get_guid(QOF_INSTANCE(book));
|
||||
guid = qof_entity_get_guid(QOF_INSTANCE(book));
|
||||
guid_string = guid_to_string(guid);
|
||||
|
||||
/* Find the filename to use. This returns the data from the
|
||||
|
Loading…
Reference in New Issue
Block a user