Tracking: Perform tracking and solving from a locked interface

Solves stability issues with possibly doing destructive changes to the
tracking setup. Locking interface is the simplest and most reliable way
to avoid crashes.

It is still possible to run non-destructive changes such as clip view
navigation. More operations can be marked as safe if needed.

Fixes T67012: Software closes when a processing marker is deleted
This commit is contained in:
Sergey Sharybin 2019-09-13 11:48:22 +02:00
parent 49c36d3430
commit 592a3d7b47
Notes: blender-bot 2023-02-14 06:42:54 +01:00
Referenced by issue #67012, Software closes when a processing marker is deleted
2 changed files with 17 additions and 1 deletions

View File

@ -50,6 +50,7 @@
/********************** solve camera operator *********************/
typedef struct {
struct wmWindowManager *wm;
Scene *scene;
MovieClip *clip;
MovieClipUser user;
@ -78,6 +79,7 @@ static bool solve_camera_initjob(
/* Could fail if footage uses images with different sizes. */
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
scj->wm = CTX_wm_manager(C);
scj->clip = clip;
scj->scene = scene;
scj->reports = op->reports;
@ -88,6 +90,8 @@ static bool solve_camera_initjob(
tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats");
WM_set_locked_interface(scj->wm, true);
return true;
}
@ -114,6 +118,8 @@ static void solve_camera_freejob(void *scv)
MovieClip *clip = scj->clip;
int solved;
WM_set_locked_interface(scj->wm, false);
if (!scj->context) {
/* job weren't fully initialized due to some error */
MEM_freeN(scj);

View File

@ -59,6 +59,7 @@ typedef struct TrackMarkersJob {
float delay; /* Delay in milliseconds to allow
* tracking at fixed FPS */
struct wmWindowManager *wm;
struct Main *main;
struct Scene *scene;
struct bScreen *screen;
@ -202,7 +203,15 @@ static bool track_markers_initjob(bContext *C, TrackMarkersJob *tmj, bool backwa
tmj->main = CTX_data_main(C);
tmj->screen = CTX_wm_screen(C);
return track_markers_check_direction(backwards, tmj->sfra, tmj->efra);
tmj->wm = CTX_wm_manager(C);
if (!track_markers_check_direction(backwards, tmj->sfra, tmj->efra)) {
return false;
}
WM_set_locked_interface(tmj->wm, true);
return true;
}
static void track_markers_startjob(void *tmv, short *stop, short *do_update, float *progress)
@ -281,6 +290,7 @@ static void track_markers_freejob(void *tmv)
{
TrackMarkersJob *tmj = (TrackMarkersJob *)tmv;
tmj->clip->tracking_context = NULL;
WM_set_locked_interface(tmj->wm, false);
BKE_autotrack_context_free(tmj->context);
MEM_freeN(tmj);
}