r20412 - gnucash/trunk/src/import-export - Add some more sanity checking in common importer module.

Christian Stimming cstim at code.gnucash.org
Sun Mar 13 07:15:40 EDT 2011


Author: cstim
Date: 2011-03-13 07:14:22 -0400 (Sun, 13 Mar 2011)
New Revision: 20412
Trac: http://svn.gnucash.org/trac/changeset/20412

Modified:
   gnucash/trunk/src/import-export/import-account-matcher.c
   gnucash/trunk/src/import-export/import-backend.c
   gnucash/trunk/src/import-export/import-main-matcher.c
   gnucash/trunk/src/import-export/import-main-matcher.h
Log:
Add some more sanity checking in common importer module.

Modified: gnucash/trunk/src/import-export/import-account-matcher.c
===================================================================
--- gnucash/trunk/src/import-export/import-account-matcher.c	2011-03-13 09:58:55 UTC (rev 20411)
+++ gnucash/trunk/src/import-export/import-account-matcher.c	2011-03-13 11:14:22 UTC (rev 20412)
@@ -269,7 +269,7 @@
     }
     else
     {
-        retval_name = xaccAccountGetName(retval);
+        retval_name = retval ? xaccAccountGetName(retval) : NULL;
         ok_pressed_retval = TRUE; /* There was no dialog involved, so the computer "pressed" ok */
     }
     /*FIXME: DEBUG("WRITEME: gnc_import_select_account() Here we should check if account type is compatible, currency matches, etc.\n"); */

Modified: gnucash/trunk/src/import-export/import-backend.c
===================================================================
--- gnucash/trunk/src/import-export/import-backend.c	2011-03-13 09:58:55 UTC (rev 20411)
+++ gnucash/trunk/src/import-export/import-backend.c	2011-03-13 11:14:22 UTC (rev 20412)
@@ -1124,6 +1124,7 @@
 
     /* Look for an online_id in the first split */
     source_split = xaccTransGetSplit(trans, 0);
+    g_assert(source_split);
 
     /* DEBUG("%s%d%s","Checking split ",i," for duplicates"); */
     dest_acct = xaccSplitGetAccount(source_split);
@@ -1151,13 +1152,16 @@
 gnc_import_TransInfo_new (Transaction *trans, GncImportMatchMap *matchmap)
 {
     GNCImportTransInfo *transaction_info;
+    Split *split;
     g_assert (trans);
 
     transaction_info = g_new0(GNCImportTransInfo, 1);
 
     transaction_info->trans = trans;
     /* Only use first split, the source split */
-    transaction_info->first_split = xaccTransGetSplit(trans, 0);
+    split = xaccTransGetSplit(trans, 0);
+    g_assert(split);
+    transaction_info->first_split = split;
 
     /* Try to find a previously selected destination account
        string match for the ADD action */

Modified: gnucash/trunk/src/import-export/import-main-matcher.c
===================================================================
--- gnucash/trunk/src/import-export/import-main-matcher.c	2011-03-13 09:58:55 UTC (rev 20411)
+++ gnucash/trunk/src/import-export/import-main-matcher.c	2011-03-13 11:14:22 UTC (rev 20412)
@@ -611,6 +611,7 @@
     GtkTreeSelection *selection;
     gchar *tmp, *imbalance, *text, *color;
     const gchar *ro_text;
+    Split *split;
     g_assert (gui);
     g_assert (model);
     g_assert (info);
@@ -620,8 +621,9 @@
     gtk_list_store_set(store, iter, DOWNLOADED_COL_DATA, info, -1);
 
     /*Account:*/
-    ro_text =
-        xaccAccountGetName(xaccSplitGetAccount(gnc_import_TransInfo_get_fsplit (info)));
+    split = gnc_import_TransInfo_get_fsplit (info);
+    g_assert(split); // Must not be NULL
+    ro_text = xaccAccountGetName(xaccSplitGetAccount(split));
     gtk_list_store_set(store, iter, DOWNLOADED_COL_ACCOUNT, ro_text, -1);
 
     /*Date*/
@@ -633,8 +635,8 @@
 
     /*Amount*/
     ro_text = xaccPrintAmount
-              (xaccSplitGetAmount (gnc_import_TransInfo_get_fsplit(info) ),
-               gnc_split_amount_print_info(gnc_import_TransInfo_get_fsplit(info), TRUE)
+              (xaccSplitGetAmount (split),
+               gnc_split_amount_print_info(split, TRUE)
               );
     gtk_list_store_set(store, iter, DOWNLOADED_COL_AMOUNT, ro_text, -1);
 
@@ -643,7 +645,7 @@
     gtk_list_store_set(store, iter, DOWNLOADED_COL_DESCRIPTION, ro_text, -1);
 
     /*Memo*/
-    ro_text = xaccSplitGetMemo(gnc_import_TransInfo_get_fsplit(info) );
+    ro_text = xaccSplitGetMemo(split);
     gtk_list_store_set(store, iter, DOWNLOADED_COL_MEMO, ro_text, -1);
 
     /*Actions*/
@@ -860,4 +862,10 @@
     }
 }
 
+GtkWidget *gnc_gen_trans_list_widget (GNCImportMainMatcher *info)
+{
+    g_assert(info);
+    return info->dialog;
+}
+
 /** @} */

Modified: gnucash/trunk/src/import-export/import-main-matcher.h
===================================================================
--- gnucash/trunk/src/import-export/import-main-matcher.h	2011-03-13 09:58:55 UTC (rev 20411)
+++ gnucash/trunk/src/import-export/import-main-matcher.h	2011-03-13 11:14:22 UTC (rev 20412)
@@ -108,5 +108,9 @@
  */
 gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info);
 
+/** Returns the widget of this dialog.
+ */
+GtkWidget *gnc_gen_trans_list_widget (GNCImportMainMatcher *info);
+
 #endif
 /**@}*/



More information about the gnucash-changes mailing list