Skip to content

Commit

Permalink
Revert b5f5129 using gnc_list_length_cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Nov 2, 2021
1 parent 3dfdf60 commit 79d8ef0
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 24 deletions.
7 changes: 4 additions & 3 deletions gnucash/gnome-utils/gnc-main-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "gnc-state.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include <gnc-glib-utils.h>
#include "gnc-uri-utils.h"
#include "gnc-version.h"
#include "gnc-warnings.h"
Expand Down Expand Up @@ -1446,7 +1447,7 @@ gnc_main_window_delete_event (GtkWidget *window,
if (already_dead)
return TRUE;

if (active_windows && active_windows->next)
if (gnc_list_length_cmp (active_windows, 1) > 0)
{
gint response;
GtkWidget *dialog;
Expand Down Expand Up @@ -1478,7 +1479,7 @@ gnc_main_window_delete_event (GtkWidget *window,
return TRUE;
}

if (active_windows && active_windows->next)
if (gnc_list_length_cmp (active_windows, 1) > 0)
return FALSE;

already_dead = gnc_main_window_quit(GNC_MAIN_WINDOW(window));
Expand Down Expand Up @@ -3348,7 +3349,7 @@ gnc_main_window_close_page (GncPluginPage *page)
/* remove the preference callbacks from the main window */
gnc_main_window_remove_prefs (window);
}
if (window && active_windows && active_windows->next)
if (window && (gnc_list_length_cmp (active_windows, 1) > 0))
gtk_widget_destroy (GTK_WIDGET(window));
}
}
Expand Down
5 changes: 3 additions & 2 deletions gnucash/gnome/dialog-imap-editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include <gnc-glib-utils.h>
#include "Account.h"

#define DIALOG_IMAP_CM_CLASS "dialog-imap-edit"
Expand Down Expand Up @@ -251,7 +252,7 @@ gnc_imap_dialog_delete (ImapDialog *imap_dialog)
list = gtk_tree_selection_get_selected_rows (selection, &fmodel);

// Make sure we have some rows selected
if (list == NULL)
if (!gnc_list_length_cmp (list, 0))
return;

// reset the invalid map total
Expand Down Expand Up @@ -645,7 +646,7 @@ get_imap_info (ImapDialog *imap_dialog, Account *acc, const gchar *category, con
else
head = IMAP_FRAME;

if (imap_list != NULL)
if (gnc_list_length_cmp (imap_list, 0))
{
PINFO("List length is %d", g_list_length (imap_list));

Expand Down
5 changes: 3 additions & 2 deletions gnucash/gnome/dialog-invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "gncOwner.h"
#include "gncInvoice.h"
#include "gncInvoiceP.h"
#include <gnc-glib-utils.h>

#include "gncEntryLedger.h"

Expand Down Expand Up @@ -3237,7 +3238,7 @@ multi_post_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_dat
gboolean test;
InvoiceWindow *iw;

if (invoice_list == NULL)
if (!gnc_list_length_cmp (invoice_list, 0))
return;
// Get the posting parameters for these invoices
iw = gnc_ui_invoice_edit(dialog, invoice_list->data);
Expand Down Expand Up @@ -3287,7 +3288,7 @@ multi_print_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_da
{
struct multi_edit_invoice_data meid;

if (invoice_list == NULL)
if (!gnc_list_length_cmp (invoice_list, 0))
return;

meid.user_data = user_data;
Expand Down
3 changes: 2 additions & 1 deletion gnucash/gnome/dialog-payment.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include <gnc-glib-utils.h>
#include "qof.h"
#include "gnc-date.h"
#include "gnc-date-edit.h"
Expand Down Expand Up @@ -1735,7 +1736,7 @@ static GList *select_txn_lots (GtkWindow *parent, Transaction *txn, Account **po
/* If the txn has both APAR splits linked to a business lot and
* splits that are not, issue a warning some will be discarded.
*/
if (has_no_lot_apar_splits && (txn_lots != NULL))
if (has_no_lot_apar_splits && gnc_list_length_cmp (txn_lots, 0))
{
GtkWidget *dialog;
char *split_str = g_strdup ("");
Expand Down
5 changes: 3 additions & 2 deletions gnucash/gnome/dialog-price-edit-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "swig-runtime.h"
#include "guile-mappings.h"
#include "gnc-engine-guile.h"
#include <gnc-glib-utils.h>


#define DIALOG_PRICE_DB_CM_CLASS "dialog-price-edit-db"
Expand Down Expand Up @@ -366,7 +367,7 @@ selection_changed_cb (GtkTreeSelection *selection, gpointer data)
PricesDialog *pdb_dialog = data;
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(pdb_dialog->remove_view));
GList *rows = gtk_tree_selection_get_selected_rows (selection, &model);
gboolean have_rows = (rows != NULL);
gboolean have_rows = (gnc_list_length_cmp (rows, 0));

change_source_flag (PRICE_REMOVE_SOURCE_COMM, have_rows, pdb_dialog);
g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
Expand Down Expand Up @@ -547,7 +548,7 @@ gnc_prices_dialog_add_clicked (GtkWidget *widget, gpointer data)
}
else if (comm_list) // selection contains price parent rows
{
if (!comm_list->next) // make sure it is only one parent
if (!gnc_list_length_cmp (comm_list, 1)) // make sure it is only one parent
{
price = gnc_price_create (pdb_dialog->book);
gnc_price_set_commodity (price, comm_list->data);
Expand Down
5 changes: 3 additions & 2 deletions gnucash/gnome/dialog-sx-editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "gnc-ui-util.h"
#include "gnucash-sheet.h"
#include "gnc-session.h"
#include <gnc-glib-utils.h>

#include "gnc-split-reg.h"

Expand Down Expand Up @@ -579,7 +580,7 @@ gnc_sxed_check_endpoint (GncSxEditorDialog *sxed)

g_date_clear (&nextDate, 1);
gnc_frequency_save_to_recurrence (sxed->gncfreq, &schedule, &startDate);
if (schedule != NULL)
if (gnc_list_length_cmp (schedule, 0))
{
g_date_subtract_days (&startDate, 1);
recurrenceListNextInstance (schedule, &startDate, &nextDate);
Expand Down Expand Up @@ -1766,7 +1767,7 @@ _sx_engine_event_handler (QofInstance *ent, QofEventId event_type, gpointer user
book = qof_instance_get_book (QOF_INSTANCE (acct));
affected_sxes = gnc_sx_get_sxes_referencing_account (book, acct);

if (affected_sxes == NULL)
if (!gnc_list_length_cmp (affected_sxes, 0))
return;

{
Expand Down
5 changes: 3 additions & 2 deletions gnucash/gnome/dialog-sx-editor2.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "gnc-ui-util.h"
#include "gnc-tree-model-split-reg.h"
#include "gnc-tree-control-split-reg.h"
#include <gnc-glib-utils.h>

#include "gnc-sx-instance-model.h"
#include "dialog-sx-since-last-run.h"
Expand Down Expand Up @@ -836,7 +837,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed)

g_date_clear (&nextDate, 1);
gnc_frequency_save_to_recurrence (sxed->gncfreq, &schedule, &startDate);
if (schedule != NULL)
if (gnc_list_length_cmp (schedule, 0))
{
g_date_subtract_days (&startDate, 1);
recurrenceListNextInstance (schedule, &startDate, &nextDate);
Expand Down Expand Up @@ -1704,7 +1705,7 @@ _sx_engine_event_handler (QofInstance *ent, QofEventId event_type, gpointer user
book = qof_instance_get_book (QOF_INSTANCE (acct));
affected_sxes = gnc_sx_get_sxes_referencing_account (book, acct);

if (affected_sxes == NULL)
if (!gnc_list_length_cmp (affected_sxes, 0))
return;

{
Expand Down
5 changes: 3 additions & 2 deletions gnucash/gnome/gnc-plugin-page-account-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "window-main-summarybar.h"
#include "dialog-object-references.h"
#include "dialog-find-account.h"
#include <gnc-glib-utils.h>

/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI;
Expand Down Expand Up @@ -593,7 +594,7 @@ gnc_plugin_page_account_tree_open (Account *account, GtkWindow *win)
page_list = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME);

// If we have a window, look for account page in that window
if (page_list != NULL)
if (gnc_list_length_cmp (page_list, 0))
{
if (win != NULL)
{
Expand Down Expand Up @@ -1500,7 +1501,7 @@ account_subaccount (Account* account)
{
Account* subaccount = NULL;
GList *subs = gnc_account_get_children (account);
if (subs && !subs->next)
if (!gnc_list_length_cmp (subs, 1))
subaccount = subs->data;
g_list_free (subs);
return subaccount;
Expand Down
6 changes: 3 additions & 3 deletions gnucash/gnome/gnc-plugin-page-sx-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ gnc_plugin_page_sx_list_cmd_edit (GtkAction *action, GncPluginPageSxList *page)

selection = gtk_tree_view_get_selection (priv->tree_view);
selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
if (selected_paths == NULL)
if (!gnc_list_length_cmp (selected_paths, 0))
{
g_warning ("no selection edit.");
return;
Expand Down Expand Up @@ -792,7 +792,7 @@ gnc_plugin_page_sx_list_cmd_edit2 (GtkAction *action, GncPluginPageSxList *page)

selection = gtk_tree_view_get_selection (priv->tree_view);
selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
if (selected_paths == NULL)
if (!gnc_list_length_cmp (selected_paths, 0))
{
g_warning ("no selection edit.");
return;
Expand Down Expand Up @@ -853,7 +853,7 @@ gnc_plugin_page_sx_list_cmd_delete (GtkAction *action, GncPluginPageSxList *page

selection = gtk_tree_view_get_selection (priv->tree_view);
selected_paths = gtk_tree_selection_get_selected_rows (selection, &model);
if (selected_paths == NULL)
if (!gnc_list_length_cmp (selected_paths, 0))
{
g_warning ("no selection for delete.");
return;
Expand Down
3 changes: 2 additions & 1 deletion gnucash/register/ledger-core/gnc-ledger-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "gnc-ledger-display.h"
#include "gnc-prefs.h"
#include "gnc-ui-util.h"
#include <gnc-glib-utils.h>
#include "split-register-control.h"
#include "split-register-model.h"

Expand Down Expand Up @@ -429,7 +430,7 @@ gnc_ledger_display_gl (void)
tRoot = gnc_book_get_template_root (gnc_get_current_book());
al = gnc_account_get_descendants (tRoot);

if (al != NULL)
if (gnc_list_length_cmp (al, 0))
xaccQueryAddAccountMatch (query, al, QOF_GUID_MATCH_NONE, QOF_QUERY_AND);

g_list_free (al);
Expand Down
5 changes: 2 additions & 3 deletions libgnucash/engine/Recurrence.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include "gnc-date.h"
#include "Account.h"
#include <stdint.h>
#include <stdint.h>
#include <stdint.h>
#include <gnc-glib-utils.h>

#define LOG_MOD "gnc.engine.recurrence"
static QofLogModule log_module = LOG_MOD;
Expand Down Expand Up @@ -556,7 +555,7 @@ recurrenceWeekendAdjustFromString(const gchar *str)
gboolean
recurrenceListIsSemiMonthly(GList *recurrences)
{
if (!(recurrences && recurrences->next && !recurrences->next->next))
if (gnc_list_length_cmp (recurrences, 2))
return FALSE;

// should be a "semi-monthly":
Expand Down
3 changes: 2 additions & 1 deletion libgnucash/engine/gncIDSearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
**********************************************************************/

#include "gncIDSearch.h"
#include <gnc-glib-utils.h>

typedef enum
{ UNDEFINED,
Expand Down Expand Up @@ -122,7 +123,7 @@ static void * search(QofBook * book, const gchar *id, void * object, GncSearchTy
result = qof_query_run (q);

// now compare _exactly_
if (result != NULL)
if (gnc_list_length_cmp (result, 0))
{
result = g_list_first (result);

Expand Down

0 comments on commit 79d8ef0

Please sign in to comment.