From aefbb8e4fafe6725b3875c3c568c45cc0be20c41 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 5 Aug 2014 23:45:16 +0200 Subject: [PATCH] ag_db_save_identical can now compare based only on chart-related data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way the chart won’t get recalculated on a name change. --- src/ag-db.c | 10 +++++----- src/ag-db.h | 4 +++- src/ag-window.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ag-db.c b/src/ag-db.c index 2a77b80..4bd1fdd 100644 --- a/src/ag-db.c +++ b/src/ag-db.c @@ -1060,7 +1060,7 @@ string_collate(const gchar *str1, const gchar *str2) * with string_collate()), FALSE otherwise */ gboolean -ag_db_save_identical(const AgDbSave *a, const AgDbSave *b) +ag_db_save_identical(const AgDbSave *a, const AgDbSave *b, gboolean chart_only) { if (a == b) { return TRUE; @@ -1070,15 +1070,15 @@ ag_db_save_identical(const AgDbSave *a, const AgDbSave *b) return FALSE; } - if (string_collate(a->name, b->name) != 0) { + if (!chart_only && string_collate(a->name, b->name) != 0) { return FALSE; } - if (string_collate(a->country, b->country) != 0) { + if (!chart_only && string_collate(a->country, b->country) != 0) { return FALSE; } - if (string_collate(a->city, b->city) != 0) { + if (!chart_only && string_collate(a->city, b->city) != 0) { return FALSE; } @@ -1126,7 +1126,7 @@ ag_db_save_identical(const AgDbSave *a, const AgDbSave *b) return FALSE; } - if (string_collate(a->note, b->note) != 0) { + if (!chart_only && string_collate(a->note, b->note) != 0) { return FALSE; } diff --git a/src/ag-db.h b/src/ag-db.h index d22303b..1c53812 100644 --- a/src/ag-db.h +++ b/src/ag-db.h @@ -68,7 +68,9 @@ GList *ag_db_get_chart_list(AgDb *db, GError **err); AgDbSave *ag_db_get_chart_data_by_id(AgDb *db, guint row_id, GError **err); -gboolean ag_db_save_identical(const AgDbSave *a, const AgDbSave *b); +gboolean ag_db_save_identical(const AgDbSave *a, + const AgDbSave *b, + gboolean chart_only); #define AG_DB_ERROR (ag_db_error_quark()) GQuark ag_db_error_quark(void); diff --git a/src/ag-window.c b/src/ag-window.c index 970e680..140af15 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -108,7 +108,7 @@ ag_window_can_close(AgWindow *window, gboolean display_dialog) save_data = ag_chart_get_db_save(priv->chart, db_id); if ( - !ag_db_save_identical(priv->saved_data, save_data) + !ag_db_save_identical(priv->saved_data, save_data, FALSE) || !(priv->saved_data) || (priv->saved_data->db_id == -1) ) {