OpenGL render: Bugfix (unreported) after rB6f92604e539b2114763150fb1ace60d28e59a889
authorThomas Beck <software@plasmasolutions.de>
Fri, 16 Sep 2016 22:21:34 +0000 (00:21 +0200)
committerThomas Beck <software@plasmasolutions.de>
Fri, 16 Sep 2016 22:21:34 +0000 (00:21 +0200)
Crashes occured immediately when clicking on "OpenGL render image" because there was only a task pool created previously when it was an animation. Solved it by introducing a variable is_animation to the openglrender and omitting the task_pool call when it's no animation.

@sergey: Please check my changes, moved the pool_ok and the lock into the is_animation clause.

source/blender/editors/render/render_opengl.c

index ee2772ce31a0270423316ffa8767bdecaf2ceb85..a154791f8f721d1d22be78aa3ca1b6bf4db25829 100644 (file)
@@ -133,6 +133,7 @@ typedef struct OGLRender {
 
        TaskPool *task_pool;
        bool pool_ok;
+       bool is_animation;
        SpinLock reports_lock;
 
 #ifdef DEBUG_TIME
@@ -636,6 +637,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
        oglrender->cfrao = scene->r.cfra;
 
        oglrender->write_still = is_write_still && !is_animation;
+       oglrender->is_animation = is_animation;
 
        oglrender->views_len = BKE_scene_multiview_num_views_get(&scene->r);
 
@@ -701,12 +703,12 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
                        oglrender->task_pool = BLI_task_pool_create(task_scheduler,
                                                                    oglrender);
                }
+               oglrender->pool_ok = true;
+               BLI_spin_init(&oglrender->reports_lock);
        }
        else {
                oglrender->task_pool = NULL;
        }
-       oglrender->pool_ok = true;
-       BLI_spin_init(&oglrender->reports_lock);
 
 #ifdef DEBUG_TIME
        oglrender->time_start = PIL_check_seconds_timer();
@@ -721,9 +723,11 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
        Scene *scene = oglrender->scene;
        int i;
 
-       BLI_task_pool_work_and_wait(oglrender->task_pool);
-       BLI_task_pool_free(oglrender->task_pool);
-       BLI_spin_end(&oglrender->reports_lock);
+       if (oglrender->is_animation) {
+               BLI_task_pool_work_and_wait(oglrender->task_pool);
+               BLI_task_pool_free(oglrender->task_pool);
+               BLI_spin_end(&oglrender->reports_lock);
+       }
 
 #ifdef DEBUG_TIME
        printf("Total render time: %f\n", PIL_check_seconds_timer() - oglrender->time_start);