From f20826ccf7f8daf909b0a9408dd03288a1401774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Wed, 25 Sep 2019 17:54:26 +0200 Subject: [PATCH] LayerSettings: Fix layer_settings_load_from_csv() * Add stacked position to layer settings * Check if layer_settings instance is valid --- layer/layer-settings.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/layer/layer-settings.c b/layer/layer-settings.c index c1c3167..66d03de 100644 --- a/layer/layer-settings.c +++ b/layer/layer-settings.c @@ -314,10 +314,14 @@ int layer_settings_load_from_csv(LayerSettings *settings, const char *path) GInputStream *in_stream; GDataInputStream *data_stream; int parser_ret; + int stacked_pos; struct layer_info linfo; file = g_file_new_for_path(path); in_stream = G_INPUT_STREAM(g_file_read(file, NULL, NULL)); + + g_return_val_if_fail(GDS_RENDER_IS_LAYER_SETTINGS(settings), -2); + if (!in_stream) { ret = -1; goto ret_destroy_file; @@ -327,11 +331,14 @@ int layer_settings_load_from_csv(LayerSettings *settings, const char *path) data_stream = g_data_input_stream_new(in_stream); + stacked_pos = 0; while ((parser_ret = layer_settings_load_csv_line_from_stream(data_stream, &linfo)) >= 0) { /* Line broken */ if (parser_ret == 1) continue; + linfo.stacked_position = stacked_pos++; + layer_settings_append_layer_info(settings, &linfo); /* Clear name to prevent memory leak */ if (linfo.name)