solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit 1a036246678bfe847f13ff1b3f811e5f007fafc7
parent e03b22958c4fe37189044f59f4098d493187600e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri,  7 Apr 2017 10:53:35 +0200

Minor fix of the solstice object creation

Stop the object creation process if its associated materials cannot be
retrieved without error.

Diffstat:
Msrc/solstice_object.c | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/solstice_object.c b/src/solstice_object.c @@ -500,11 +500,17 @@ create_shaded_shape res_T res = RES_OK; ASSERT(solstice && ssol_front && ssol_back && ssol_shape); + *ssol_front = NULL; + *ssol_back = NULL; + *ssol_shape = NULL; + obj = solparser_get_object(solstice->parser, obj_id); mtl2 = solparser_get_material_double_sided(solstice->parser, obj->mtl2); - solstice_create_ssol_material(solstice, mtl2->front, ssol_front); - solstice_create_ssol_material(solstice, mtl2->back, ssol_back); + res = solstice_create_ssol_material(solstice, mtl2->front, ssol_front); + if(res != RES_OK) goto error; + res = solstice_create_ssol_material(solstice, mtl2->back, ssol_back); + if(res != RES_OK) goto error; /* Define the shape transformation */ rotation[0] = MDEG2RAD(obj->rotation[0]); @@ -547,7 +553,15 @@ create_shaded_shape break; default: FATAL("Unreachable code.\n"); break; } + if(res != RES_OK) goto error; + +exit: return res; +error: + if(*ssol_front) SSOL(material_ref_put(*ssol_front)); + if(*ssol_back) SSOL(material_ref_put(*ssol_back)); + if(*ssol_shape) SSOL(shape_ref_put(*ssol_shape)); + goto exit; } /*******************************************************************************