Fix preview render not starting in some cases, now starts the preview rendering
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 26 Apr 2013 13:47:57 +0000 (13:47 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 26 Apr 2013 13:47:57 +0000 (13:47 +0000)
job if no render result is found and no preview render job is already running.

source/blender/editors/render/render_preview.c

index e8c578cb685c511289a48c03acaa9961fe2f96af..2e88c243df6f14dca0c0f145f8a0d88b258abeeb 100644 (file)
@@ -572,9 +572,6 @@ static int ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, r
                        }
                }
        }
-       else {
-               ok = 1;
-       }
 
        RE_ReleaseResultImage(re);
 
@@ -584,6 +581,7 @@ static int ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, r
 void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
 {
        if (idp) {
+               wmWindowManager *wm = CTX_wm_manager(C);
                ScrArea *sa = CTX_wm_area(C);
                ID *id = (ID *)idp;
                ID *parent = (ID *)parentp;
@@ -609,13 +607,11 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
                if (ok)
                        *rect = newrect;
 
-               /* check for spacetype... */
-               if (sbuts->spacetype == SPACE_BUTS && sbuts->preview) {
+               /* start a new preview render job if signalled through sbuts->preview,
+                * or if no render result was found and no preview render job is running */
+               if ((sbuts->spacetype == SPACE_BUTS && sbuts->preview) ||
+                       (!ok && !WM_jobs_test(wm, sa, WM_JOB_TYPE_RENDER_PREVIEW))) {
                        sbuts->preview = 0;
-                       ok = 0;
-               }
-       
-               if (ok == 0) {
                        ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
                }
        }