[grisbi-cvs] grisbi/src gsb_form.c, 1.125, 1.126 gsb_form_widget.c, 1.33, 1.34

Pierre Biava pbiava at users.sourceforge.net
Sun Jun 7 13:48:14 CEST 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24821/src

Modified Files:
	gsb_form.c gsb_form_widget.c 
Log Message:
fixed a crash of the application in a particular configuration of the form of the transactions

Index: gsb_form.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- gsb_form.c	25 May 2009 19:42:27 -0000	1.125
+++ gsb_form.c	7 Jun 2009 11:48:11 -0000	1.126
@@ -1459,21 +1459,21 @@
     /* the entry can be a combofix or a real entry */
     if (GTK_IS_COMBOFIX ( entry ))
     {
-	if ( gsb_form_widget_check_empty (GTK_COMBOFIX (entry) -> entry))
-	{
-	    gtk_combofix_set_text ( GTK_COMBOFIX (entry), "" );
-	    gsb_form_widget_set_empty ( GTK_COMBOFIX (entry) -> entry,
-					FALSE );
-	}
+        if ( gsb_form_widget_check_empty (GTK_COMBOFIX (entry) -> entry))
+        {
+            gtk_combofix_set_text ( GTK_COMBOFIX (entry), "" );
+            gsb_form_widget_set_empty ( GTK_COMBOFIX (entry) -> entry,
+                        FALSE );
+        }
     }
     else
     {
-	if ( gsb_form_widget_check_empty (entry) )
-	{
-	    gtk_entry_set_text ( GTK_ENTRY (entry), "" );
-	    gsb_form_widget_set_empty ( entry,
-					FALSE );
-	}
+        if ( gsb_form_widget_check_empty (entry) )
+        {
+            gtk_entry_set_text ( GTK_ENTRY (entry), "" );
+            gsb_form_widget_set_empty ( entry,
+                        FALSE );
+        }
     }
     /* sensitive the valid and cancel buttons */
     gtk_widget_set_sensitive (GTK_WIDGET (form_button_valid), TRUE);
@@ -1482,8 +1482,7 @@
     /* set the financial year on automatic by default */
     fyear_button = gsb_form_widget_get_widget (TRANSACTION_FORM_EXERCICE);
     if (fyear_button)
-	gsb_fyear_set_combobox_history ( fyear_button,
-					 0 );
+        gsb_fyear_set_combobox_history ( fyear_button, 0 );
 
     return FALSE;
 }
@@ -1508,7 +1507,6 @@
     gint account_number;
     gint transaction_number;
 
-    devel_debug (NULL);
     /* still not found, if change the content of the form, something come in entry
      * wich is nothing, so protect here */
     if ( !GTK_IS_WIDGET (entry)
@@ -1540,7 +1538,7 @@
 
     /* string will be filled only if the field is empty */
     string = NULL;
-
+    devel_debug_int (element_number);
     switch ( element_number )
     {
     case TRANSACTION_FORM_PARTY :
@@ -1582,7 +1580,7 @@
                 gtk_widget_hide ( gsb_form_widget_get_widget ( TRANSACTION_FORM_CHEQUE ) );
 
             widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA );
-            if ( GTK_WIDGET_VISIBLE ( widget ) )
+            if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
                 gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
                                             TRANSACTION_FORM_CONTRA ),
                                             GSB_PAYMENT_CREDIT,
@@ -1627,7 +1625,7 @@
                                             TRANSACTION_FORM_CHEQUE ) );
 
                     widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA);
-                    if ( GTK_WIDGET_VISIBLE (widget))
+                    if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
                         gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
                                             TRANSACTION_FORM_CONTRA ),
                                             GSB_PAYMENT_DEBIT,
@@ -1671,7 +1669,7 @@
                 gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
 
             widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA);
-            if ( GTK_WIDGET_VISIBLE (widget))
+            if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
                 gsb_payment_method_create_combo_list ( widget,
                         GSB_PAYMENT_DEBIT,
                         account_number, 0 );
@@ -1710,12 +1708,12 @@
                     
                     /* if there is no payment method, the last function hide it, but we have
                      * to hide the cheque element too */
-                    if ( !GTK_WIDGET_VISIBLE (widget))
+                    if ( !GTK_WIDGET_VISIBLE ( widget ) )
                         gtk_widget_hide (gsb_form_widget_get_widget (
                                             TRANSACTION_FORM_CHEQUE ) );
 
                     widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA);
-                    if ( GTK_WIDGET_VISIBLE (widget))
+                    if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
                         gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
                                             TRANSACTION_FORM_CONTRA ),
                                             GSB_PAYMENT_CREDIT,

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- gsb_form_widget.c	25 May 2009 19:42:27 -0000	1.33
+++ gsb_form_widget.c	7 Jun 2009 11:48:11 -0000	1.34
@@ -766,16 +766,15 @@
 
         /* we change the payment method to adapt it for the debit */
         /* empty the credit */
-        widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT);
-        if (!gsb_form_widget_check_empty (widget))
+        widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CREDIT );
+        if ( !gsb_form_widget_check_empty ( widget ) )
         {
             old_credit = g_strdup ( gtk_entry_get_text ( GTK_ENTRY (
                         gsb_form_widget_get_widget ( TRANSACTION_FORM_CREDIT ) ) ) );
             printf ("old_credit = %s\n", old_credit );
-            gtk_entry_set_text ( GTK_ENTRY (widget),
-                     gsb_form_widget_get_name (TRANSACTION_FORM_CREDIT));
-            gsb_form_widget_set_empty ( widget,
-                        TRUE );
+            gtk_entry_set_text ( GTK_ENTRY ( widget ),
+                     gsb_form_widget_get_name ( TRANSACTION_FORM_CREDIT ) );
+            gsb_form_widget_set_empty ( widget, TRUE );
         }
 
         widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE);
@@ -784,27 +783,28 @@
          * (if grey, it's a child of split so do nothing) */
         if ( widget
              &&
-             GTK_WIDGET_SENSITIVE (widget))
+             GTK_WIDGET_SENSITIVE ( widget ) )
         {
             /* change the signe of the method of payment and the contra */
-            if ( gsb_payment_method_get_combo_sign (widget) == GSB_PAYMENT_CREDIT)
+            if ( gsb_payment_method_get_combo_sign ( widget ) == GSB_PAYMENT_CREDIT )
             {
                 gsb_payment_method_create_combo_list ( widget,
-                                       GSB_PAYMENT_DEBIT,
-                                       account_number, 0 );
+                                        GSB_PAYMENT_DEBIT,
+                                        account_number, 0 );
                 /* if there is no payment method, the last function hide it, but we have
                  * to hide the cheque element too */
-                if ( !GTK_WIDGET_VISIBLE (widget))
+                if ( ! GTK_WIDGET_VISIBLE (widget) )
                     gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
 
-                widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA);
-                if ( GTK_WIDGET_VISIBLE (widget))
-                    gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA),
-                                       GSB_PAYMENT_CREDIT,
-                                       account_number, 0 );
+                widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA );
+                if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
+                    gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
+                                        TRANSACTION_FORM_CONTRA ),
+                                        GSB_PAYMENT_CREDIT,
+                                        account_number, 0 );
             }
         }
-        gsb_form_check_auto_separator (entry);
+        gsb_form_check_auto_separator ( entry );
         break;
     case TRANSACTION_FORM_CREDIT :
          /* on met old_credit = NULl car avec g_free plantage */
@@ -813,16 +813,15 @@
 
         /* we change the payment method to adapt it for the debit */
         /* empty the credit */
-        widget = gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT);
-        if (!gsb_form_widget_check_empty (widget))
+        widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_DEBIT );
+        if ( !gsb_form_widget_check_empty ( widget ) )
         {
             old_debit = g_strdup ( gtk_entry_get_text ( GTK_ENTRY (
                         gsb_form_widget_get_widget ( TRANSACTION_FORM_DEBIT ) ) ) );
             printf ("old_debit = %s\n", old_debit );
             gtk_entry_set_text ( GTK_ENTRY (widget),
-                     gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT));
-            gsb_form_widget_set_empty ( widget,
-                        TRUE );
+                        gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT));
+            gsb_form_widget_set_empty ( widget, TRUE );
         }
         widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE);
 
@@ -836,18 +835,18 @@
             if ( gsb_payment_method_get_combo_sign (widget) == GSB_PAYMENT_DEBIT)
             {
                 gsb_payment_method_create_combo_list ( widget,
-                                       GSB_PAYMENT_CREDIT,
-                                       account_number, 0 );
+                                        GSB_PAYMENT_CREDIT,
+                                        account_number, 0 );
                 /* if there is no payment method, the last function hide it, but we have
                  * to hide the cheque element too */
                 if ( !GTK_WIDGET_VISIBLE (widget))
                     gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
 
                 widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA);
-                if ( GTK_WIDGET_VISIBLE (widget))
+                if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
                     gsb_payment_method_create_combo_list ( widget,
-                                       GSB_PAYMENT_DEBIT,
-                                       account_number, 0 );
+                                        GSB_PAYMENT_DEBIT,
+                                        account_number, 0 );
             }
         }
         gsb_form_check_auto_separator (entry);



More information about the cvs mailing list