]> Dogcows Code - chaz/homebank/blobdiff - src/hb-category.c
Merge branch 'master' into ext-perl
[chaz/homebank] / src / hb-category.c
index 807e93d92d01e3db514282527aca69b2b34922af..948788649f591bcd242a47e0c898993beff7ce08 100644 (file)
@@ -1,5 +1,5 @@
 /*  HomeBank -- Free, easy, personal accounting for everyone.
- *  Copyright (C) 1995-2017 Maxime DOYEN
+ *  Copyright (C) 1995-2018 Maxime DOYEN
  *
  *  This file is part of HomeBank.
  *
@@ -20,6 +20,9 @@
 #include "homebank.h"
 #include "hb-category.h"
 
+#include "ext.h"
+#include "refcount.h"
+
 
 /****************************************************************************/
 /* Debug macros                                                                                 */
@@ -40,7 +43,7 @@ extern struct HomeBank *GLOBALS;
 Category *
 da_cat_clone(Category *src_item)
 {
-Category *new_item = g_memdup(src_item, sizeof(Category));
+Category *new_item = rc_dup(src_item, sizeof(Category));
 
        DB( g_print("da_cat_clone\n") );
        if(new_item)
@@ -56,12 +59,12 @@ void
 da_cat_free(Category *item)
 {
        DB( g_print("da_cat_free\n") );
-       if(item != NULL)
+       if(rc_unref(item))
        {
                DB( g_print(" => %d, %s\n", item->key, item->name) );
 
                g_free(item->name);
-               g_free(item);
+               rc_free(item);
        }
 }
 
@@ -70,7 +73,7 @@ Category *
 da_cat_malloc(void)
 {
        DB( g_print("da_cat_malloc\n") );
-       return g_malloc0(sizeof(Category));
+       return rc_alloc(sizeof(Category));
 }
 
 
@@ -467,6 +470,9 @@ guint32 *new_key;
                                newcat->imported = imported;
 
                                newcat->flags |= GF_SUB;
+                               //#1713413 take parent type into account
+                               if(parent->flags & GF_INCOME)
+                                       newcat->flags |= GF_INCOME;
 
                                DB( g_print(" -> insert subcat '%s' id: %d\n", newcat->name, newcat->key) );
 
@@ -664,6 +670,7 @@ GList *lcat;
 GList *lst_acc, *lnk_acc;
 GList *lnk_txn;
 GList *lpay, *lrul, *list;
+guint i, nbsplit;
 
        lcat = list = g_hash_table_get_values(GLOBALS->h_cat);
        while (list != NULL)
@@ -686,7 +693,20 @@ GList *lpay, *lrul, *list;
                {
                Transaction *txn = lnk_txn->data;
 
-                       category_fill_usage_count(txn->kcat);           
+                       //#1689308 count split as well
+                       if( txn->flags & OF_SPLIT )
+                       {
+                               nbsplit = da_splits_count(txn->splits);
+                               for(i=0;i<nbsplit;i++)
+                               {
+                               Split *split = txn->splits[i];
+                                       
+                                       category_fill_usage_count(split->kcat);
+                               }
+                       }
+                       else
+                               category_fill_usage_count(txn->kcat);           
+
                        lnk_txn = g_list_next(lnk_txn);
                }
                lnk_acc = g_list_next(lnk_acc);
@@ -709,7 +729,20 @@ GList *lpay, *lrul, *list;
        {
        Archive *entry = list->data;
 
-               category_fill_usage_count(entry->kcat);
+               //#1689308 count split as well
+               if( entry->flags & OF_SPLIT )
+               {
+                       nbsplit = da_splits_count(entry->splits);
+                       for(i=0;i<nbsplit;i++)
+                       {
+                       Split *split = entry->splits[i];
+                               
+                               category_fill_usage_count(split->kcat);
+                       }
+               }
+               else
+                       category_fill_usage_count(entry->kcat);
+
                list = g_list_next(list);
        }
 
This page took 0.028313 seconds and 4 git commands to generate.