ag_db_save_identical can now compare based only on chart-related data

This way the chart won’t get recalculated on a name change.
This commit is contained in:
Gergely Polonkai 2014-08-05 23:45:16 +02:00
parent 881b58080a
commit aefbb8e4fa
3 changed files with 9 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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)
) {