diff --git a/src/ag-chart.c b/src/ag-chart.c index d5cd6d3..60ea2cc 100644 --- a/src/ag-chart.c +++ b/src/ag-chart.c @@ -1315,6 +1315,7 @@ ag_chart_new_from_db_save(AgDbChartSave *save_data, ag_chart_set_country(chart, save_data->country); ag_chart_set_city(chart, save_data->city); ag_chart_set_note(chart, save_data->note); + ag_chart_set_db_id(chart, save_data->db_id); return chart; } @@ -2047,14 +2048,14 @@ ag_chart_get_note(AgChart *chart) } AgDbChartSave * -ag_chart_get_db_save(AgChart *chart, gint db_id) +ag_chart_get_db_save(AgChart *chart) { GsweCoordinates *coords; AgChartPrivate *priv = ag_chart_get_instance_private(chart); AgDbChartSave *save_data = ag_db_chart_save_new(TRUE); GsweTimestamp *timestamp = gswe_moment_get_timestamp(GSWE_MOMENT(chart)); - save_data->db_id = db_id; + save_data->db_id = priv->db_id; save_data->name = g_strdup(priv->name); save_data->country = g_strdup(priv->country); diff --git a/src/ag-chart.h b/src/ag-chart.h index 811761f..6082762 100644 --- a/src/ag-chart.h +++ b/src/ag-chart.h @@ -139,7 +139,7 @@ void ag_chart_set_note(AgChart *chart, const gchar *note); const gchar *ag_chart_get_note(AgChart *chart); -AgDbChartSave *ag_chart_get_db_save(AgChart *chart, gint db_id); +AgDbChartSave *ag_chart_get_db_save(AgChart *chart); GdkPixbuf *ag_chart_get_pixbuf(AgChart *chart, guint image_size, diff --git a/src/ag-window.c b/src/ag-window.c index 76670dc..e0a1b32 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -811,7 +811,7 @@ ag_window_recalculate_chart(AgWindow *window, gboolean set_everything) ); chart_data = (priv->chart) - ? ag_chart_get_db_save(priv->chart, db_id) + ? ag_chart_get_db_save(priv->chart) : NULL ; @@ -1213,9 +1213,6 @@ gboolean ag_window_can_close(AgWindow *window, gboolean display_dialog) { GET_PRIV(window); - gint db_id = (priv->saved_data) - ? priv->saved_data->db_id - : -1; AgDbChartSave *save_data = NULL; AgDb *db = ag_db_get(); GError *err = NULL; @@ -1223,7 +1220,7 @@ ag_window_can_close(AgWindow *window, gboolean display_dialog) if (priv->chart) { ag_window_recalculate_chart(window, TRUE); - save_data = ag_chart_get_db_save(priv->chart, db_id); + save_data = ag_chart_get_db_save(priv->chart); if ( !ag_db_chart_save_identical(priv->saved_data, save_data, FALSE) @@ -1292,14 +1289,12 @@ ag_window_save_action(GSimpleAction *action, GET_PRIV(window); AgDb *db = ag_db_get(); GError *err = NULL; - gint old_id; AgDbChartSave *save_data; ag_window_recalculate_chart(window, TRUE); if (!ag_window_can_close(window, FALSE)) { - old_id = (priv->saved_data) ? priv->saved_data->db_id : -1; - save_data = ag_chart_get_db_save(priv->chart, old_id); + save_data = ag_chart_get_db_save(priv->chart); if (!ag_db_chart_save(db, save_data, &err)) { ag_app_message_dialog( @@ -2827,7 +2822,7 @@ ag_window_set_chart(AgWindow *window, AgChart *chart) window ); g_object_ref(chart); - priv->saved_data = ag_chart_get_db_save(chart, -1); + priv->saved_data = ag_chart_get_db_save(chart); } else { priv->saved_data = NULL; }