Add a populated parameter to ag_db_chart_save_new()
If the caller intends to fill the whole struct, this should be set to TRUE
This commit is contained in:
parent
6656f52959
commit
2177ac2c41
@ -1997,7 +1997,7 @@ ag_chart_get_db_save(AgChart *chart, gint db_id)
|
||||
{
|
||||
GsweCoordinates *coords;
|
||||
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
|
||||
AgDbChartSave *save_data = ag_db_chart_save_new();
|
||||
AgDbChartSave *save_data = ag_db_chart_save_new(TRUE);
|
||||
GsweTimestamp *timestamp = gswe_moment_get_timestamp(GSWE_MOMENT(chart));
|
||||
GEnumClass *house_system_class;
|
||||
GEnumValue *house_system_enum;
|
||||
|
15
src/ag-db.c
15
src/ag-db.c
@ -659,6 +659,14 @@ ag_db_chart_save(AgDb *db, AgDbChartSave *save_data, GError **err)
|
||||
note = G_VALUE_INIT;
|
||||
AgDbPrivate *priv = ag_db_get_instance_private(db);
|
||||
|
||||
if (save_data == NULL) {
|
||||
g_error("Trying to save a NULL chart!");
|
||||
}
|
||||
|
||||
if (!save_data->populated) {
|
||||
g_error("Only populated chart data can be saved!");
|
||||
}
|
||||
|
||||
g_value_init(&name, G_TYPE_STRING);
|
||||
g_value_set_string(&name, save_data->name);
|
||||
|
||||
@ -828,12 +836,13 @@ ag_db_chart_save(AgDb *db, AgDbChartSave *save_data, GError **err)
|
||||
}
|
||||
|
||||
AgDbChartSave *
|
||||
ag_db_chart_save_new(void)
|
||||
ag_db_chart_save_new(gboolean populated)
|
||||
{
|
||||
AgDbChartSave *save_data;
|
||||
|
||||
save_data = g_new0(AgDbChartSave, 1);
|
||||
save_data->refcount = 1;
|
||||
save_data->populated = populated;
|
||||
|
||||
return save_data;
|
||||
}
|
||||
@ -874,7 +883,7 @@ ag_db_chart_get_list(AgDb *db, GError **err)
|
||||
|
||||
while (gda_data_model_iter_move_next(iter)) {
|
||||
const GValue *value;
|
||||
AgDbChartSave *save_data = ag_db_chart_save_new();
|
||||
AgDbChartSave *save_data = ag_db_chart_save_new(FALSE);
|
||||
|
||||
value = gda_data_model_iter_get_value_at(iter, 0);
|
||||
save_data->db_id = g_value_get_int(value);
|
||||
@ -951,7 +960,7 @@ ag_db_chart_get_data_by_id(AgDb *db, guint row_id, GError **err)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
save_data = ag_db_chart_save_new();
|
||||
save_data = ag_db_chart_save_new(TRUE);
|
||||
|
||||
/* id */
|
||||
value = gda_data_model_get_value_at(
|
||||
|
@ -50,6 +50,7 @@ struct _AgDbClass {
|
||||
|
||||
typedef struct _AgDbChartSave {
|
||||
gint db_id;
|
||||
gboolean populated;
|
||||
gchar *name;
|
||||
gchar *country;
|
||||
gchar *city;
|
||||
@ -84,7 +85,7 @@ gboolean ag_db_chart_save(AgDb *db,
|
||||
AgDbChartSave *save_data,
|
||||
GError **err);
|
||||
|
||||
AgDbChartSave *ag_db_chart_save_new(void);
|
||||
AgDbChartSave *ag_db_chart_save_new(gboolean populated);
|
||||
|
||||
AgDbChartSave *ag_db_chart_save_ref(AgDbChartSave *save_data);
|
||||
|
||||
|
@ -736,7 +736,7 @@ ag_window_recalculate_chart(AgWindow *window, gboolean set_everything)
|
||||
gtk_spin_button_update(GTK_SPIN_BUTTON(current));
|
||||
}
|
||||
|
||||
edit_data = ag_db_chart_save_new();
|
||||
edit_data = ag_db_chart_save_new(TRUE);
|
||||
|
||||
edit_data->db_id = db_id;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user