Fix T76320: Thread race condition on undo with prefetching enabled

Stop prefetch jobs before undoing.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7633
This commit is contained in:
Richard Antalik 2020-05-13 00:10:58 +02:00
parent be69f23b68
commit 50ef801a79
Notes: blender-bot 2023-02-14 07:39:44 +01:00
Referenced by issue #76320, Video Editor: seq_prefetch_cache_is_full while undoing
Referenced by issue #76274, Program crashes when editing a video file, corrupted it.
3 changed files with 14 additions and 0 deletions

View File

@ -360,6 +360,7 @@ bool BKE_sequencer_cache_is_full(struct Scene *scene);
* ********************************************************************** */
void BKE_sequencer_prefetch_start(const SeqRenderData *context, float cfra, float cost);
void BKE_sequencer_prefetch_stop_all();
void BKE_sequencer_prefetch_stop(struct Scene *scene);
void BKE_sequencer_prefetch_free(struct Scene *scene);
bool BKE_sequencer_prefetch_need_redraw(struct Main *bmain, struct Scene *scene);

View File

@ -42,6 +42,7 @@
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
@ -242,6 +243,14 @@ static void seq_prefetch_update_area(PrefetchJob *pfjob)
}
}
void BKE_sequencer_prefetch_stop_all(void)
{
/*TODO(Richard): Use wm_jobs for prefetch, or pass main. */
for (Scene *scene = G.main->scenes.first; scene; scene = scene->id.next) {
BKE_sequencer_prefetch_stop(scene);
}
}
/* Use also to update scene and context changes
* This function should almost always be called by cache invalidation, not directly.
*/

View File

@ -35,6 +35,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_sequencer.h"
#include "WM_api.h"
#include "WM_types.h"
@ -558,6 +559,9 @@ void WM_jobs_kill_all(wmWindowManager *wm)
while ((wm_job = wm->jobs.first)) {
wm_jobs_kill_job(wm, wm_job);
}
/* This job will be automatically restarted */
BKE_sequencer_prefetch_stop_all();
}
/* wait until every job ended, except for one owner (used in undo to keep screen job alive) */