mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Owner tree: fix crash when modifying owner name
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20624 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6310fc2040
commit
8183cf116d
@ -394,6 +394,14 @@ gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b)
|
||||
return (a->owner.undefined == b->owner.undefined);
|
||||
}
|
||||
|
||||
int gncOwnerGCompareFunc (const GncOwner *a, const GncOwner *b)
|
||||
{
|
||||
if (gncOwnerEqual (a, b))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * gncOwnerGetID (const GncOwner *owner)
|
||||
{
|
||||
if (!owner) return NULL;
|
||||
|
@ -130,8 +130,17 @@ void gncOwnerSetActive (const GncOwner *owner, gboolean active);
|
||||
/** @} */
|
||||
|
||||
void gncOwnerCopy (const GncOwner *src, GncOwner *dest);
|
||||
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
|
||||
int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
|
||||
|
||||
/** \name Comparison routines.
|
||||
@{
|
||||
*/
|
||||
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b); /** Check if both objects refer to the same owner type
|
||||
if and the owner reference points to the same
|
||||
{vendor/customer/employee} in memory */
|
||||
int gncOwnerGCompareFunc (const GncOwner *a, const GncOwner *b); /** Same as gncOwnerEqual, but returns 0 if
|
||||
equal to be used as a GList custom compare function */
|
||||
int gncOwnerCompare (const GncOwner *a, const GncOwner *b); /** Sort on name */
|
||||
/** @} */
|
||||
|
||||
/** Get the GncGUID of the immediate owner */
|
||||
const GncGUID * gncOwnerGetGUID (const GncOwner *owner);
|
||||
|
@ -941,13 +941,13 @@ gnc_tree_model_owner_get_iter_from_owner (GncTreeModelOwner *model,
|
||||
gnc_leave_return_val_if_fail ((owner != NULL), FALSE);
|
||||
gnc_leave_return_val_if_fail ((iter != NULL), FALSE);
|
||||
|
||||
iter->user_data = owner;
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
|
||||
owner_in_list = g_list_find (priv->owner_list, (gconstpointer)owner);
|
||||
owner_in_list = g_list_find_custom (priv->owner_list, (gconstpointer)owner, (GCompareFunc)gncOwnerGCompareFunc);
|
||||
if (owner_in_list)
|
||||
{
|
||||
iter->stamp = model->stamp;
|
||||
iter->user_data = owner_in_list->data;
|
||||
iter->user_data2 = GINT_TO_POINTER (g_list_position (priv->owner_list, owner_in_list));
|
||||
iter->user_data3 = NULL;
|
||||
LEAVE("iter %s", iter_to_string (iter));
|
||||
@ -955,6 +955,8 @@ gnc_tree_model_owner_get_iter_from_owner (GncTreeModelOwner *model,
|
||||
}
|
||||
else
|
||||
{
|
||||
iter->stamp = 0;
|
||||
iter->user_data = NULL;
|
||||
LEAVE("Owner not found in list");
|
||||
return FALSE;
|
||||
}
|
||||
@ -1056,13 +1058,13 @@ gnc_tree_model_owner_event_handler (QofInstance *entity,
|
||||
entity, event_type, model, ed);
|
||||
priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
|
||||
|
||||
qofOwnerSetEntity (&owner, entity);
|
||||
if (qof_instance_get_book (QOF_INSTANCE(&owner)) != priv->book)
|
||||
if (qof_instance_get_book (entity) != priv->book)
|
||||
{
|
||||
LEAVE("not in this book");
|
||||
return;
|
||||
}
|
||||
if (!g_list_find (priv->owner_list, (gconstpointer)&owner))
|
||||
qofOwnerSetEntity (&owner, entity);
|
||||
if (!gnc_tree_model_owner_get_iter_from_owner (model, &owner, &iter))
|
||||
{
|
||||
LEAVE("not in this model");
|
||||
return;
|
||||
@ -1073,7 +1075,7 @@ gnc_tree_model_owner_event_handler (QofInstance *entity,
|
||||
case QOF_EVENT_ADD:
|
||||
/* Tell the filters/views where the new owner was added. */
|
||||
DEBUG("add owner %p (%s)", &owner, gncOwnerGetName(&owner));
|
||||
path = gnc_tree_model_owner_get_path_from_owner(model, &owner);
|
||||
path = gnc_tree_model_owner_get_path(GTK_TREE_MODEL(model), &iter);
|
||||
if (!path)
|
||||
{
|
||||
DEBUG("can't generate path");
|
||||
@ -1106,7 +1108,7 @@ gnc_tree_model_owner_event_handler (QofInstance *entity,
|
||||
|
||||
case QOF_EVENT_MODIFY:
|
||||
DEBUG("modify owner %p (%s)", &owner, gncOwnerGetName(&owner));
|
||||
path = gnc_tree_model_owner_get_path_from_owner(model, &owner);
|
||||
path = gnc_tree_model_owner_get_path(GTK_TREE_MODEL(model), &iter);
|
||||
if (!path)
|
||||
{
|
||||
DEBUG("can't generate path");
|
||||
|
Loading…
Reference in New Issue
Block a user