Fix race condition between tracking thread and tracks map sync
This might have been a reason of bug T38281.
This commit is contained in:
parent
83617d24d5
commit
910f4df45d
|
@ -669,11 +669,10 @@ bool BKE_tracking_context_step(MovieTrackingContext *context)
|
|||
dst_pixel_x, dst_pixel_y);
|
||||
}
|
||||
|
||||
#pragma omp critical
|
||||
{
|
||||
tracking_insert_new_marker(context, track, marker, curfra, tracked,
|
||||
frame_width, frame_height, dst_pixel_x, dst_pixel_y);
|
||||
}
|
||||
BLI_spin_lock(&context->tracks_map->spin_lock);
|
||||
tracking_insert_new_marker(context, track, marker, curfra, tracked,
|
||||
frame_width, frame_height, dst_pixel_x, dst_pixel_y);
|
||||
BLI_spin_unlock(&context->tracks_map->spin_lock);
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ TracksMap *tracks_map_new(const char *object_name, bool is_camera, int num_track
|
|||
|
||||
map->hash = BLI_ghash_ptr_new("TracksMap hash");
|
||||
|
||||
BLI_spin_init(&map->spin_lock);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -139,6 +141,8 @@ void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
|
|||
if (BLI_findindex(old_tracks, old_track) != -1) {
|
||||
BLI_remlink(old_tracks, old_track);
|
||||
|
||||
BLI_spin_lock(&map->spin_lock);
|
||||
|
||||
/* Copy flags like selection back to the track map. */
|
||||
track->flag = old_track->flag;
|
||||
track->pat_flag = old_track->pat_flag;
|
||||
|
@ -149,6 +153,8 @@ void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
|
|||
*old_track = *track;
|
||||
old_track->markers = MEM_dupallocN(old_track->markers);
|
||||
|
||||
BLI_spin_unlock(&map->spin_lock);
|
||||
|
||||
BLI_addtail(&tracks, old_track);
|
||||
|
||||
mapped_to_old = true;
|
||||
|
@ -210,6 +216,9 @@ void tracks_map_free(TracksMap *map, void (*customdata_free)(void *customdata))
|
|||
MEM_freeN(map->customdata);
|
||||
|
||||
MEM_freeN(map->tracks);
|
||||
|
||||
BLI_spin_end(&map->spin_lock);
|
||||
|
||||
MEM_freeN(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#ifndef __TRACKING_PRIVATE_H__
|
||||
#define __TRACKING_PRIVATE_H__
|
||||
|
||||
#include "BLI_threads.h"
|
||||
|
||||
struct GHash;
|
||||
struct MovieTracking;
|
||||
struct MovieTrackingMarker;
|
||||
|
@ -54,6 +56,9 @@ typedef struct TracksMap {
|
|||
struct GHash *hash;
|
||||
|
||||
int ptr;
|
||||
|
||||
/* Spin lock is used to sync context during tracking. */
|
||||
SpinLock spin_lock;
|
||||
} TracksMap;
|
||||
|
||||
struct TracksMap *tracks_map_new(const char *object_name, bool is_camera, int num_tracks, int customdata_size);
|
||||
|
|
|
@ -160,8 +160,9 @@ static void clip_draw_dopesheet_background(ARegion *ar, MovieClip *clip)
|
|||
int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->start_frame);
|
||||
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->end_frame);
|
||||
|
||||
if (coverage_segment->coverage == TRACKING_COVERAGE_BAD)
|
||||
if (coverage_segment->coverage == TRACKING_COVERAGE_BAD) {
|
||||
glColor4f(1.0f, 0.0f, 0.0f, 0.07f);
|
||||
}
|
||||
else
|
||||
glColor4f(1.0f, 1.0f, 0.0f, 0.07f);
|
||||
|
||||
|
|
Loading…
Reference in New Issue