Fix T49996: VSE opengl render crash with grease pencil if current frame is empty
authorAntonioya <blendergit@gmail.com>
Fri, 11 Nov 2016 21:27:10 +0000 (22:27 +0100)
committerAntonioya <blendergit@gmail.com>
Fri, 11 Nov 2016 21:27:10 +0000 (22:27 +0100)
If the opengl render with grease pencil is run from VSE with the current
frame outside visible frames, the render pass is wrong and the render
must be canceled because nothing to render. Related to #T49975

source/blender/editors/render/render_opengl.c

index ea53c8764f2a9fc5c8c9c0af48b0edaa7ad62488..16842efb4366955a27fa7b08b3cef318a19e1dcf 100644 (file)
@@ -485,23 +485,24 @@ static void add_gpencil_renderpass(OGLRender *oglrender, RenderResult *rr, Rende
                /* copy image data from rectf */
                // XXX: Needs conversion.
                unsigned char *src = (unsigned char *)RE_RenderViewGetById(rr, oglrender->view_id)->rect32;
-               float *dest = rp->rect;
-
-               int x, y, rectx, recty;
-               rectx = rr->rectx;
-               recty = rr->recty;
-               for (y = 0; y < recty; y++) {
-                       for (x = 0; x < rectx; x++) {
-                               unsigned char *pixSrc = src + 4 * (rectx * y + x);
-                               if (pixSrc[3] > 0) {
-                                       float *pixDest = dest + 4 * (rectx * y + x);
-                                       float float_src[4];
-                                       srgb_to_linearrgb_uchar4(float_src, pixSrc);
-                                       addAlphaOverFloat(pixDest, float_src);
+               if (src != NULL) {
+                       float *dest = rp->rect;
+
+                       int x, y, rectx, recty;
+                       rectx = rr->rectx;
+                       recty = rr->recty;
+                       for (y = 0; y < recty; y++) {
+                               for (x = 0; x < rectx; x++) {
+                                       unsigned char *pixSrc = src + 4 * (rectx * y + x);
+                                       if (pixSrc[3] > 0) {
+                                               float *pixDest = dest + 4 * (rectx * y + x);
+                                               float float_src[4];
+                                               srgb_to_linearrgb_uchar4(float_src, pixSrc);
+                                               addAlphaOverFloat(pixDest, float_src);
+                                       }
                                }
                        }
                }
-
                /* back layer status */
                i = 0;
                for (bGPDlayer *gph = gpd->layers.first; gph; gph = gph->next) {