@ -31,6 +31,7 @@
# include "qofid-p.h"
static QofLogModule log_module = QOF_MOD_ENGINE ;
static gboolean qof_alt_dirty_mode = FALSE ;
struct QofCollection_s
{
@ -43,6 +44,20 @@ struct QofCollection_s
/* =============================================================== */
gboolean
qof_get_alt_dirty_mode ( void )
{
return qof_alt_dirty_mode ;
}
void
qof_set_alt_dirty_mode ( gboolean enabled )
{
qof_alt_dirty_mode = enabled ;
}
/* =============================================================== */
static void qof_collection_remove_entity ( QofEntity * ent ) ;
void
@ -182,7 +197,8 @@ qof_collection_remove_entity (QofEntity *ent)
col = ent - > collection ;
if ( ! col ) return ;
g_hash_table_remove ( col - > hash_of_entities , & ent - > guid ) ;
qof_collection_mark_dirty ( col ) ;
if ( ! qof_alt_dirty_mode )
qof_collection_mark_dirty ( col ) ;
ent - > collection = NULL ;
}
@ -194,7 +210,8 @@ qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
g_return_if_fail ( col - > e_type = = ent - > e_type ) ;
qof_collection_remove_entity ( ent ) ;
g_hash_table_insert ( col - > hash_of_entities , & ent - > guid , ent ) ;
qof_collection_mark_dirty ( col ) ;
if ( ! qof_alt_dirty_mode )
qof_collection_mark_dirty ( col ) ;
ent - > collection = col ;
}
@ -210,7 +227,8 @@ qof_collection_add_entity (QofCollection *coll, QofEntity *ent)
e = qof_collection_lookup_entity ( coll , & ent - > guid ) ;
if ( e ! = NULL ) { return FALSE ; }
g_hash_table_insert ( coll - > hash_of_entities , & ent - > guid , ent ) ;
qof_collection_mark_dirty ( coll ) ;
if ( ! qof_alt_dirty_mode )
qof_collection_mark_dirty ( coll ) ;
return TRUE ;
}
@ -342,6 +360,14 @@ qof_collection_mark_dirty (QofCollection *col)
if ( col ) { col - > is_dirty = TRUE ; }
}
void
qof_collection_print_dirty ( QofCollection * col , gpointer dummy )
{
if ( col - > is_dirty )
printf ( " %s collection is dirty. \n " , col - > e_type ) ;
qof_collection_foreach ( col , qof_instance_print_dirty , NULL ) ;
}
/* =============================================================== */
gpointer