Add more error handling to command line interface to handle empty layer mapping spec

This commit is contained in:
Mario Hüttel 2019-11-16 23:42:48 +01:00
parent 02720ec37b
commit 519d2296ad

View File

@ -146,6 +146,7 @@ int command_line_convert_gds(const char *gds_name,
double scale) double scale)
{ {
int ret = -1; int ret = -1;
int render_ret;
GList *libs = NULL; GList *libs = NULL;
int res; int res;
GList *renderer_list = NULL; GList *renderer_list = NULL;
@ -163,7 +164,14 @@ int command_line_convert_gds(const char *gds_name,
/* Load layer_settings */ /* Load layer_settings */
layer_sett = layer_settings_new(); layer_sett = layer_settings_new();
layer_settings_load_from_csv(layer_sett, layer_file); if (!layer_sett)
goto return_value;
ret = layer_settings_load_from_csv(layer_sett, layer_file);
if (ret) {
fprintf(stderr, _("Loading layer mapping file failed.\n"));
goto ret_destroy_layer_mapping;
}
/* Create renderers */ /* Create renderers */
if (create_renderers(renderers, output_file_names, tex_layers, tex_standalone, if (create_renderers(renderers, output_file_names, tex_layers, tex_standalone,
@ -221,7 +229,9 @@ int command_line_convert_gds(const char *gds_name,
/* Execute all rendererer instances */ /* Execute all rendererer instances */
for (list_iter = renderer_list; list_iter; list_iter = list_iter->next) { for (list_iter = renderer_list; list_iter; list_iter = list_iter->next) {
current_renderer = GDS_RENDER_OUTPUT_RENDERER(list_iter->data); current_renderer = GDS_RENDER_OUTPUT_RENDERER(list_iter->data);
gds_output_renderer_render_output(current_renderer, toplevel_cell, scale); render_ret = gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
if (render_ret)
fprintf(stderr, "Rendering failed with error code: %d\n", render_ret);
} }
ret_destroy_library_list: ret_destroy_library_list:
@ -231,6 +241,7 @@ ret_clear_renderers:
g_object_unref(list_iter->data); g_object_unref(list_iter->data);
ret_destroy_layer_mapping: ret_destroy_layer_mapping:
g_object_unref(layer_sett); g_object_unref(layer_sett);
return_value:
return ret; return ret;
} }