Bugfix #33004
authorTon Roosendaal <ton@blender.org>
Mon, 29 Oct 2012 17:41:19 +0000 (17:41 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 29 Oct 2012 17:41:19 +0000 (17:41 +0000)
Screencast recording stopped on a undo/redo. This was because all thread jobs
were killed then. Now it leaves screen jobs (screen cast) running, that's
data that doesn't change on undos.

Also renamed jobs_stop_all() to jobs_kill_all() - it terminates threads.

source/blender/blenkernel/intern/blender.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c

index c6fa2de65457258c60df4c8fa0b5b36bb5258e13..e1e868b234ee23f8f21cd52d10f92430f8f40e0e 100644 (file)
@@ -485,7 +485,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
        int success = 0, fileflags;
        
        /* This is needed so undoing/redoing doesn't crash with threaded previews going */
-       WM_jobs_stop_all(CTX_wm_manager(C));
+       WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
 
        BLI_strncpy(mainstr, G.main->name, sizeof(mainstr));    /* temporal store */
 
index ad9b082d0448d371d6c3960499f612058ba506da..fe802abc3a973c829f979a03d040ae9170c6bcbe 100644 (file)
@@ -497,8 +497,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
                return OPERATOR_CANCELLED;
        }
        
-       /* stop all running jobs, currently previews frustrate Render */
-       WM_jobs_stop_all(CTX_wm_manager(C));
+       /* stop all running jobs, except screen one. currently previews frustrate Render */
+       WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
 
        /* get main */
        if (G.debug_value == 101) {
index 0b6b5cb8e4a542198e5f241ea266684752cabd05..e4592a4f77ead512a44cc776b4bf1047d62393c3 100644 (file)
@@ -333,8 +333,8 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
                return 0;
        }
 
-       /* stop all running jobs, currently previews frustrate Render */
-       WM_jobs_stop_all(CTX_wm_manager(C));
+       /* stop all running jobs, except screen one. currently previews frustrate Render */
+       WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
 
        /* create offscreen buffer */
        sizex = (scene->r.size * scene->r.xsch) / 100;
index e7b7f679ce3c972a7ea9f8c57d389a1df06dd665..04e8b65a2efcd470a35d96c22b7fa4fb862572f9 100644 (file)
@@ -357,8 +357,9 @@ void        WM_jobs_callbacks(struct wmJob *,
 void           WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
 void           WM_jobs_stop(struct wmWindowManager *wm, void *owner, void *startjob);
 void           WM_jobs_kill(struct wmWindowManager *wm, void *owner, void (*)(void *, short int *, short int *, float *));
-void           WM_jobs_stop_all(struct wmWindowManager *wm);
-
+void           WM_jobs_kill_all(struct wmWindowManager *wm);
+       void            WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
+       
 int                    WM_jobs_has_running(struct wmWindowManager *wm);
 
                        /* clipboard */
index bb8c434dfb57a9b2fa7e7826ba771776eb3cd1a9..6124b03778d0a638b283fd12980eb30c29999d1f 100644 (file)
@@ -144,7 +144,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
        /* code copied from wm_init_exit.c */
        for (wm = wmlist->first; wm; wm = wm->id.next) {
                
-               WM_jobs_stop_all(wm);
+               WM_jobs_kill_all(wm);
                
                for (win = wm->windows.first; win; win = win->next) {
                
index 89fa92b7373c43ad3bea4425af32b1a599b5ab3d..6d4a84d789659fc0f0b6621db55cd1ea37f11526 100644 (file)
@@ -372,7 +372,7 @@ void WM_exit_ext(bContext *C, const short do_python)
        if (C && wm) {
                wmWindow *win;
 
-               WM_jobs_stop_all(wm);
+               WM_jobs_kill_all(wm);
 
                for (win = wm->windows.first; win; win = win->next) {
                        
index 0917d7660514eddc44bb9dc96470cdaa8c772f92..42d721327b6f6c3a94ec8ae1e142673b8bfa667e 100644 (file)
@@ -360,7 +360,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
        }
 }
 
-/* stop job, free data completely */
+/* stop job, end thread, free data completely */
 static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
 {
        if (wm_job->running) {
@@ -385,7 +385,8 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
        
 }
 
-void WM_jobs_stop_all(wmWindowManager *wm)
+/* wait until every job ended */
+void WM_jobs_kill_all(wmWindowManager *wm)
 {
        wmJob *wm_job;
        
@@ -394,6 +395,18 @@ void WM_jobs_stop_all(wmWindowManager *wm)
        
 }
 
+/* wait until every job ended, except for one owner (used in undo to keep screen job alive) */
+void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner)
+{
+       wmJob *wm_job;
+       
+       for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+               if (wm_job->owner != owner)
+                       wm_jobs_kill_job(wm, wm_job);
+       }
+}
+
+
 /* signal job(s) from this owner or callback to stop, timer is required to get handled */
 void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
 {