Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2014-06-19 02:46:34 +0400
committerDalai Felinto <dfelinto@gmail.com>2014-06-19 02:46:37 +0400
commitb49e6d04ccb672029478d681133efae9842ba330 (patch)
treeae3e072a76d7c7c1032dd6996084a9c0fba80e25 /source
parent9cf66d9248f4d99857365b06de6b7a1fa4c3f563 (diff)
Bake-API: small cleanup to prevent unfreed memory when there are baking errors
Fix to be included in 2.71
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/object/object_bake_api.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 6e291e438cd..78c037dc629 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -551,6 +551,13 @@ static int bake(
re = RE_NewRender(scene->id.name);
RE_SetReports(re, NULL);
+ RE_bake_engine_set_engine_parameters(re, bmain, scene);
+
+ if (!RE_bake_has_engine(re)) {
+ BKE_report(reports, RPT_ERROR, "Current render engine does not support baking");
+ goto cleanup;
+ }
+
tot_materials = ob_low->totcol;
if (uv_layer && uv_layer[0] != '\0') {
@@ -640,8 +647,6 @@ static int bake(
}
}
- RE_bake_engine_set_engine_parameters(re, bmain, scene);
-
/* blender_test_break uses this global */
G.is_break = false;
@@ -753,35 +758,32 @@ static int bake(
me_low, pixel_array_low, highpoly, tot_highpoly, num_pixels, ob_cage != NULL,
cage_extrusion, ob_low->obmat, (ob_cage ? ob_cage->obmat : ob_low->obmat), me_cage)) {
BKE_report(reports, RPT_ERROR, "Error handling selected objects");
- goto cleanup;
+ goto cage_cleanup;
}
/* the baking itself */
for (i = 0; i < tot_highpoly; i++) {
- if (RE_bake_has_engine(re)) {
- ok = RE_bake_engine(re, highpoly[i].ob, highpoly[i].pixel_array, num_pixels,
- depth, pass_type, result);
- }
- else {
- BKE_report(reports, RPT_ERROR, "Current render engine does not support baking");
- goto cleanup;
+ ok = RE_bake_engine(re, highpoly[i].ob, highpoly[i].pixel_array, num_pixels,
+ depth, pass_type, result);
+ if (!ok) {
+ BKE_reportf(reports, RPT_ERROR, "Error baking from object \"%s\"", highpoly[i].ob->id.name + 2);
+ goto cage_cleanup;
}
-
- if (!ok)
- break;
}
+cage_cleanup:
/* reverting data back */
- if (ob_cage) {
- ob_cage->restrictflag = restrict_flag_cage;
- }
- else if (is_cage) {
+ if ((ob_cage == NULL) && is_cage) {
ob_low->modifiers = modifiers_original;
while ((md = BLI_pophead(&modifiers_tmp))) {
modifier_free(md);
}
}
+
+ if (!ok) {
+ goto cleanup;
+ }
}
else {
/* make sure low poly renders */