[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_5-192-g8fb838b

Pierre Biava nobody at users.sourceforge.net
Sat Nov 10 19:12:38 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".

The branch, master has been updated
       via  8fb838b3c70361cf17c20c60a40bc7531db6db63 (commit)
      from  0b7b3bc9f34513354fa702102c8d70f7d0797c47 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8fb838b3c70361cf17c20c60a40bc7531db6db63
Author: pbiava <pierre.biava at nerim.net>
Date:   Sat Nov 10 19:08:06 2012 +0100

    fixed bug 1531 : crash when delete an account

-----------------------------------------------------------------------

Changes:
diff --git a/src/fenetre_principale.c b/src/fenetre_principale.c
index 517a8f6..115afef 100644
--- a/src/fenetre_principale.c
+++ b/src/fenetre_principale.c
@@ -272,9 +272,9 @@ gboolean gsb_gui_fill_general_notebook ( GtkWidget *notebook )
                         gsb_account_property_create_page (),
                         gtk_label_new ( _("Properties") ) );
 
-    g_signal_connect ( G_OBJECT (account_page),
-                        "switch_page",
-                        G_CALLBACK (gsb_gui_on_account_switch_page),
+    g_signal_connect ( G_OBJECT ( account_page ),
+                        "switch-page",
+                        G_CALLBACK ( gsb_gui_on_account_switch_page ),
                         NULL );
 
     /* append the scheduled transactions page */
diff --git a/src/gsb_account.c b/src/gsb_account.c
index b62390e..658b044 100644
--- a/src/gsb_account.c
+++ b/src/gsb_account.c
@@ -29,7 +29,9 @@
 
 /*START_INCLUDE*/
 #include "gsb_account.h"
+#include "categories_onglet.h"
 #include "dialog.h"
+#include "fenetre_principale.h"
 #include "gsb_account_property.h"
 #include "gsb_category.h"
 #include "gsb_data_account.h"
@@ -39,28 +41,24 @@
 #include "gsb_data_transaction.h"
 #include "gsb_file.h"
 #include "gsb_form_scheduler.h"
-#include "navigation.h"
-#include "fenetre_principale.h"
-#include "menu.h"
 #include "gsb_real.h"
 #include "gsb_scheduler_list.h"
+#include "gsb_transactions_list.h"
+#include "imputation_budgetaire.h"
 #include "main.h"
-#include "traitement_variables.h"
+#include "menu.h"
+#include "navigation.h"
+#include "structures.h"
 #include "tiers_onglet.h"
-#include "categories_onglet.h"
-#include "imputation_budgetaire.h"
+#include "traitement_variables.h"
 #include "transaction_list.h"
-#include "gsb_transactions_list.h"
-#include "structures.h"
+#include "erreur.h"
 /*END_INCLUDE*/
 
 /*START_STATIC*/
 /*END_STATIC*/
 
 
-
-
-
 /*START_EXTERN*/
 extern GtkWidget *account_page;
 extern gint mise_a_jour_fin_comptes_passifs;
@@ -152,9 +150,12 @@ gboolean gsb_account_new ( kind_account account_type,
 
 
 
-/** that function delete the current account selected in the account properties
- * \param none
- * \return FALSE FALSE
+/**
+ * that function delete the current account selected
+ *
+ * \param   none
+ *
+ * \return  FALSE
  * */
 gboolean gsb_account_delete ( void )
 {
@@ -164,9 +165,10 @@ gboolean gsb_account_delete ( void )
 	gchar* tmpstr;
 
     deleted_account = gsb_gui_navigation_get_current_account ();
-
+    devel_debug_int (deleted_account);
+    
     tmpstr = g_strdup_printf (_("Delete account \"%s\"?"),
-				     gsb_data_account_get_name ( deleted_account ) ) ;
+                        gsb_data_account_get_name ( deleted_account ) ) ;
 
     if ( !question_yes_no_hint ( tmpstr,
 				        _("This will irreversibly remove this account and all operations "
@@ -194,14 +196,12 @@ gboolean gsb_account_delete ( void )
         gint scheduled_number;
 
         scheduled_number = gsb_data_scheduled_get_scheduled_number ( list_tmp -> data );
+        list_tmp = list_tmp -> next;
 
         if ( gsb_data_scheduled_get_account_number (scheduled_number) == deleted_account )
             gsb_data_scheduled_remove_scheduled (scheduled_number);
-
-        list_tmp = list_tmp -> next;
     }
 
-
     /* remove all the transactions of that account */
     list_tmp = gsb_data_transaction_get_complete_transactions_list ();
     while (list_tmp)
@@ -226,6 +226,7 @@ gboolean gsb_account_delete ( void )
                 gsb_data_transaction_set_contra_transaction_number ( contra_transaction_number, -1);
 
             /* now can remove the transaction */
+            transaction_list_remove_transaction ( transaction_number );
             gsb_data_transaction_remove_transaction_without_check ( transaction_number );
         }
     }
@@ -247,52 +248,44 @@ gboolean gsb_account_delete ( void )
     /* delete the account */
     gsb_data_account_delete ( deleted_account );
 
-    /* check gsb_gui_navigation_get_current_account () and gsb_gui_navigation_get_current_account ()_onglet and put them
-     * on the first account if they are on the deleted account */
-
+    /* check gsb_gui_navigation_get_current_account () and gsb_gui_navigation_get_current_account ()_onglet
+     * and put them on the first account if they are on the deleted account */
     if ( gsb_gui_navigation_get_current_account () == deleted_account )
     {
         GtkWidget *notebook_general;
+        gint first_account;
 
-	/* update the transaction list */
-    notebook_general = gsb_gui_get_general_notebook ( );
-	page_number = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( notebook_general ) );
-
-	navigation_change_account ( gsb_data_account_first_number () );
+        /* sélection du premier compte de la liste */
+        notebook_general = gsb_gui_get_general_notebook ();
+        page_number = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( notebook_general ) );
+        first_account = gsb_data_account_first_no_closed_account ();
 
-	gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook_general ), page_number );
+        gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook_general ), page_number );
+        gsb_gui_navigation_set_selection ( 1, first_account, NULL );
+        navigation_change_account ( first_account );
     }
 
+    /* Update navigation pane. */
+    gsb_gui_navigation_remove_account ( deleted_account );
+
     /* update the buttons lists */
     gsb_menu_update_accounts_in_menus();
 
-    /* Replace trees contents. */
-    categories_fill_list ();
-    budgetary_lines_fill_list ();
-    payees_fill_list ();
-
-    /* update the categories in lists */
-    transaction_list_update_element (ELEMENT_CATEGORY);
-
     /* update the name of accounts in form */
-    gsb_account_update_combo_list ( gsb_form_scheduler_get_element_widget (SCHEDULED_FORM_ACCOUNT),
-				    FALSE );
+    gsb_account_update_combo_list ( gsb_form_scheduler_get_element_widget (SCHEDULED_FORM_ACCOUNT), FALSE );
 
-    gsb_scheduler_list_fill_list (gsb_scheduler_list_get_tree_view ());
     mise_a_jour_liste_echeances_manuelles_accueil = 1;
     mise_a_jour_liste_comptes_accueil = 1;
     mise_a_jour_soldes_minimaux = 1;
     mise_a_jour_fin_comptes_passifs = 1;
 
-    /* Update navigation pane. */
-    gsb_gui_navigation_remove_account ( deleted_account );
-
     gsb_file_set_modified ( TRUE );
+
+    /* return */
     return FALSE;
 }
 
 
-
 /**
  * create a combobox containing the list of the accounts
  *
@@ -301,7 +294,7 @@ gboolean gsb_account_delete ( void )
  * \param include_closed If set to TRUE, include the closed accounts
  *
  * \return a new GtkCombobox containing the list of the accounts
- */
+ * */
 GtkWidget *gsb_account_create_combo_list ( GCallback func,
 					   gpointer data,
 					   gboolean include_closed )
@@ -377,34 +370,46 @@ gboolean gsb_account_update_combo_list ( GtkWidget *combo_box,
     GSList *list_tmp;
     GtkListStore *store;
 
-    if (!combo_box)
-	return FALSE;
+    if ( !combo_box )
+        return FALSE;
 
-    store = GTK_LIST_STORE (gtk_combo_box_get_model ( GTK_COMBO_BOX (combo_box)));
-    gtk_list_store_clear (store);
+    g_signal_handlers_block_by_func ( G_OBJECT ( combo_box ),
+                        G_CALLBACK ( gsb_form_scheduler_change_account ),
+                        NULL );
+
+    store = GTK_LIST_STORE ( gtk_combo_box_get_model ( GTK_COMBO_BOX ( combo_box) ) );
+    gtk_list_store_clear ( store );
 
     list_tmp = gsb_data_account_get_list_accounts ();
 
     while ( list_tmp )
     {
-	gint account_number;
-	GtkTreeIter iter;
+        gint account_number;
+        GtkTreeIter iter;
 
-	account_number = gsb_data_account_get_no_account ( list_tmp -> data );
+        account_number = gsb_data_account_get_no_account ( list_tmp -> data );
 
-	if ( account_number >= 0 && ( !gsb_data_account_get_closed_account (account_number)
-				      || include_closed ) )
-	{
-	    gtk_list_store_append ( GTK_LIST_STORE (store),
-				    &iter );
-	    gtk_list_store_set ( store,
-				 &iter,
-				 0, gsb_data_account_get_name (account_number),
-				 1, account_number,
-				 -1 );
-	}
-	list_tmp = list_tmp -> next;
+        if ( account_number >= 0
+         &&
+         ( !gsb_data_account_get_closed_account ( account_number )
+           ||
+           include_closed
+         ) )
+        {
+            gtk_list_store_append ( GTK_LIST_STORE ( store ), &iter );
+            gtk_list_store_set ( store,
+                        &iter,
+                        0, gsb_data_account_get_name ( account_number ),
+                        1, account_number,
+                        -1 );
+        }
+        list_tmp = list_tmp -> next;
     }
+
+    g_signal_handlers_unblock_by_func ( G_OBJECT ( combo_box ),
+                        G_CALLBACK ( gsb_form_scheduler_change_account ),
+                        NULL );
+
     return FALSE;
 }
 
@@ -496,7 +501,7 @@ gboolean gsb_account_set_combo_account_number ( GtkWidget *combo_box,
  * \param include_closed If set to TRUE, include the closed accounts
  *
  * \return A newly created menu
- */
+ * */
 GtkWidget *gsb_account_create_menu_list ( GCallback func,
 					  gboolean activate_currrent,
 					  gboolean include_closed )
@@ -543,6 +548,13 @@ GtkWidget *gsb_account_create_menu_list ( GCallback func,
 
 
 
+/**
+ *
+ *
+ * \param
+ *
+ * \return
+ * */
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/gsb_data_account.c b/src/gsb_data_account.c
index 2c923b8..f61ece4 100644
--- a/src/gsb_data_account.c
+++ b/src/gsb_data_account.c
@@ -411,7 +411,7 @@ gint gsb_data_account_first_number ( void )
     struct_account *account;
 
     if ( !list_accounts )
-	return -1;
+        return -1;
 
     account = list_accounts -> data;
 
@@ -419,7 +419,35 @@ gint gsb_data_account_first_number ( void )
 }
 
 
+/**
+ * ind and return the first no closed account
+ *
+ * \param none
+ *
+ * \return first number of account, -1 if no accounts
+ * */
+gint gsb_data_account_first_no_closed_account ( void )
+{
+    struct_account *account;
+    GSList *list_tmp;
 
+    if ( !list_accounts )
+        return -1;
+
+    list_tmp = list_accounts;
+
+    while ( list_tmp )
+    {
+        account = list_tmp -> data;
+
+        if ( account -> closed_account == 0 )
+            break;
+
+        list_tmp = list_tmp -> next;
+    }
+
+    return  account -> account_number;
+}
 
 
 /**
diff --git a/src/gsb_data_account.h b/src/gsb_data_account.h
index c14b5bb..3f433c8 100644
--- a/src/gsb_data_account.h
+++ b/src/gsb_data_account.h
@@ -37,6 +37,7 @@ gint gsb_data_account_compare_position ( gint account_number_1,
 gboolean gsb_data_account_delete ( gint account_number );
 gboolean gsb_data_account_exists ( gint account_number );
 gint gsb_data_account_first_number ( void );
+gint gsb_data_account_first_no_closed_account ( void );
 gint gsb_data_account_get_account_by_id ( const gchar *account_id );
 GtkWidget *gsb_data_account_get_account_icon_image ( gint account_number );
 GdkPixbuf *gsb_data_account_get_account_icon_pixbuf ( gint account_number );
diff --git a/src/menu.c b/src/menu.c
index b074bfe..197155b 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -741,8 +741,8 @@ gboolean gsb_menu_update_accounts_in_menus ( void )
     GSList *list_tmp;
     GtkActionGroup * action_group;
 
-    if ( move_to_account_merge_id != -1 ) 
-	gtk_ui_manager_remove_ui ( ui_manager, move_to_account_merge_id );
+    if ( move_to_account_merge_id != -1 )
+        gtk_ui_manager_remove_ui ( ui_manager, move_to_account_merge_id );
 
     move_to_account_merge_id = gtk_ui_manager_new_merge_id ( ui_manager );
     action_group = gtk_action_group_new ( "Group3" );
@@ -752,38 +752,43 @@ gboolean gsb_menu_update_accounts_in_menus ( void )
 
     while ( list_tmp )
     {
-	gint i;
-
-	i = gsb_data_account_get_no_account ( list_tmp -> data );
-
-	if ( !gsb_data_account_get_closed_account ( i ))
-	{
-	    gchar * tmp_name = g_strdup_printf ( "MoveToAccount%d", i );
-	    gchar * account_name = gsb_data_account_get_name(i);
-	    GtkAction * action;
-
-	    if ( ! account_name )
-	    {
-		account_name = _("Unnamed account");
-	    }
-	    action = gtk_action_new ( tmp_name, account_name, "", "" );
-
-	    if ( gsb_gui_navigation_get_current_account () == i )
-		gtk_action_set_sensitive ( action, FALSE );
-
-	    gtk_action_group_add_action ( action_group, action );
-
-	    g_signal_connect ( action, "activate", 
-			       G_CALLBACK(move_selected_operation_to_account_nb), 
-			       GINT_TO_POINTER(i) );
-	    gtk_ui_manager_add_ui ( ui_manager, recent_files_merge_id, 
-				    "/menubar/EditMenu/MoveToAnotherAccount/",
-				    tmp_name, tmp_name,
-				    GTK_UI_MANAGER_MENUITEM, FALSE );
-	    g_free ( tmp_name );
-	}
-
-	list_tmp = list_tmp -> next;
+        gint i;
+
+        i = gsb_data_account_get_no_account ( list_tmp -> data );
+
+        if ( !gsb_data_account_get_closed_account ( i ) )
+        {
+            gchar *tmp_name;
+            gchar *account_name;
+            GtkAction *action;
+
+            tmp_name = g_strdup_printf ( "MoveToAccount%d", i );
+            account_name = gsb_data_account_get_name ( i );
+            if ( !account_name )
+                account_name = _("Unnamed account");
+
+            action = gtk_action_new ( tmp_name, account_name, "", "" );
+
+            if ( gsb_gui_navigation_get_current_account () == i )
+                gtk_action_set_sensitive ( action, FALSE );
+
+            gtk_action_group_add_action ( action_group, action );
+            g_signal_connect ( action,
+                        "activate",
+                        G_CALLBACK ( move_selected_operation_to_account_nb ),
+                        GINT_TO_POINTER ( i ) );
+
+            gtk_ui_manager_add_ui ( ui_manager,
+                        move_to_account_merge_id,
+                        "/menubar/EditMenu/MoveToAnotherAccount/",
+                        tmp_name,
+                        tmp_name,
+                        GTK_UI_MANAGER_MENUITEM,
+                        FALSE );
+            g_free ( tmp_name );
+        }
+
+        list_tmp = list_tmp -> next;
     }
 
     gtk_ui_manager_insert_action_group ( ui_manager, action_group, 2 );
diff --git a/src/navigation.c b/src/navigation.c
index 3928665..fd22252 100644
--- a/src/navigation.c
+++ b/src/navigation.c
@@ -940,49 +940,43 @@ gboolean navigation_change_account ( gint new_account )
     gchar *tmp_menu_path;
 
     devel_debug_int (new_account);
-
     if ( new_account < 0 )
-	return FALSE;
+        return FALSE;
 
     /* the selection on the navigation bar has already changed, so
      * have to use a buffer variable to get the last account */
     current_account = gsb_gui_navigation_get_last_account ();
 
     /* sensitive the last account in the menu */
-    tmp_menu_path = g_strconcat (
-        "/menubar/EditMenu/MoveToAnotherAccount/",
-        gsb_data_account_get_name (current_account),
-        NULL );
+    tmp_menu_path = g_strconcat ( "/menubar/EditMenu/MoveToAnotherAccount/",
+                        gsb_data_account_get_name (current_account),
+                        NULL );
     gsb_gui_sensitive_menu_item ( tmp_menu_path, TRUE );
     g_free ( tmp_menu_path );
+
     gsb_gui_sensitive_menu_item ( "/menubar/EditMenu/NewTransaction", TRUE );
 
     /* save the row_align of the last account */
     gsb_data_account_set_row_align ( current_account,
-				     gsb_transactions_list_get_row_align ( ) );
+                        gsb_transactions_list_get_row_align ( ) );
 
     /* set the appearance of the list according to the new account */
     transaction_list_sort_set_column ( gsb_data_account_get_sort_column (new_account ),
-				      gsb_data_account_get_sort_type ( new_account ) );
+                        gsb_data_account_get_sort_type ( new_account ) );
+
     gsb_transactions_list_update_tree_view ( new_account, FALSE );
-    transaction_list_select ( gsb_data_account_get_current_transaction_number ( new_account ) );
     gsb_transactions_list_set_row_align ( gsb_data_account_get_row_align ( new_account ) );
 
     /* mise en place de la date du dernier relevé */
     gsb_navigation_update_statement_label ( new_account );
 
-    tmp_menu_path = g_strconcat (
-        "/menubar/EditMenu/MoveToAnotherAccount/",
-        gsb_data_account_get_name (new_account),
-        NULL );
+    /* on met le nom insensitif dans la liste des comptes */
+    tmp_menu_path = g_strconcat ( "/menubar/EditMenu/MoveToAnotherAccount/",
+                        gsb_data_account_get_name (new_account),
+                        NULL );
     gsb_gui_sensitive_menu_item ( tmp_menu_path, FALSE );
-    g_free ( tmp_menu_path );
 
-    /* Sensitive menu items if something is selected. */
-    if ( gsb_data_account_get_current_transaction_number ( new_account ) == -1 )
-        gsb_menu_set_menus_select_transaction_sensitive ( FALSE );
-    else
-        gsb_menu_set_menus_select_transaction_sensitive ( TRUE );
+    g_free ( tmp_menu_path );
 
     /* show or hide the rules button in toolbar */
     if ( gsb_data_import_rule_account_has_rule ( new_account ) )
@@ -994,6 +988,7 @@ gboolean navigation_change_account ( gint new_account )
     if ( conf.display_grisbi_title == GSB_ACCOUNT_HOLDER )
         gsb_main_set_grisbi_title ( new_account );
 
+    /* select the good tab */
     bet_data_select_bet_pages ( new_account );
 
     /* unset the last date written */


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list