From c62aa571aa9acc004e806417701a9b1a81e17b29 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 5 Aug 2022 10:30:17 -0300 Subject: [PATCH] Possible fix rendering reference layers in nonreproducible scenario (fix #3460) This is a patch, but we don't know why this can happen, so it's highly probable that other kind of crashes might appear in the near future (or this doesn't fix the original bug). --- src/render/render.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/render/render.cpp b/src/render/render.cpp index 905a948e0..7b3b891aa 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -222,6 +222,18 @@ void composite_image_scale_up( int px_x, px_y; int px_w = int(sx); int px_h = int(sy); + + // We've received crash reports about these values being 0 when it's + // called from Render::renderImage() when the projection is scaled + // to the cel bounds (this can happen only when a reference layer is + // scaled, but when a reference layer is visible we shouldn't be + // here, we should be using the composite_image_general(), see the + // "finegrain" var in Render::getImageComposition()). + ASSERT(px_w > 0); + ASSERT(px_h > 0); + if (px_w <= 0 || px_h <= 0) + return; + int first_px_w = px_w - (area.src.x % px_w); int first_px_h = px_h - (area.src.y % px_h);