From e375804f22b2a997fb68cb40005a1b75b20d3c7a Mon Sep 17 00:00:00 2001 From: Christopher Lam <christopher.lck@gmail.com> Date: Tue, 20 Aug 2024 07:32:26 +0800 Subject: [PATCH] [gnc-plugin-page-account-tree.cpp] avoid assertion 'gas != NULL' warnings don't call gnc_account_sel_get_visible_account_num when the GncAccountSel is nullptr. --- gnucash/gnome/gnc-plugin-page-account-tree.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.cpp b/gnucash/gnome/gnc-plugin-page-account-tree.cpp index b92631b1297..b138072a00b 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.cpp +++ b/gnucash/gnome/gnc-plugin-page-account-tree.cpp @@ -1167,18 +1167,17 @@ delete_account_helper (Account * account, gpointer data) static void set_ok_sensitivity(GtkWidget *dialog) { - gint sa_mas_cnt, trans_mas_cnt; gboolean sensitive; auto sa_mas = GTK_WIDGET(g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS)); auto trans_mas = GTK_WIDGET(g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS)); - sa_mas_cnt = gnc_account_sel_get_visible_account_num(GNC_ACCOUNT_SEL(sa_mas)); - trans_mas_cnt = gnc_account_sel_get_visible_account_num(GNC_ACCOUNT_SEL(trans_mas)); - sensitive = (((NULL == sa_mas) || - (!gtk_widget_is_sensitive(sa_mas) || sa_mas_cnt)) && - ((NULL == trans_mas) || - (!gtk_widget_is_sensitive(trans_mas) || trans_mas_cnt))); + sensitive = ((!sa_mas || + !gtk_widget_is_sensitive (sa_mas) || + gnc_account_sel_get_visible_account_num (GNC_ACCOUNT_SEL (sa_mas))) && + (!trans_mas || + !gtk_widget_is_sensitive (trans_mas) || + gnc_account_sel_get_visible_account_num (GNC_ACCOUNT_SEL (trans_mas)))); auto button = GTK_WIDGET(g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON)); gtk_widget_set_sensitive(button, sensitive);