diff --git a/aegisub/src/threaded_frame_source.cpp b/aegisub/src/threaded_frame_source.cpp index 9d856423e..b44c8d40d 100644 --- a/aegisub/src/threaded_frame_source.cpp +++ b/aegisub/src/threaded_frame_source.cpp @@ -125,6 +125,8 @@ ThreadedFrameSource::ThreadedFrameSource(agi::fs::path const& video_filename, wx } ThreadedFrameSource::~ThreadedFrameSource() { + // Block until all currently queued jobs are complete + worker->Sync([]{}); } void ThreadedFrameSource::LoadSubtitles(const AssFile *new_subs) throw() { @@ -193,15 +195,9 @@ void ThreadedFrameSource::ProcAsync(uint_fast32_t req_version) { std::shared_ptr ThreadedFrameSource::GetFrame(int frame, double time, bool raw) { std::shared_ptr ret; - std::mutex m; - std::condition_variable cv; - std::unique_lock l(m); - worker->Async([&]{ - std::unique_lock l(m); + worker->Sync([&]{ ret = ProcFrame(frame, time, raw); - cv.notify_all(); }); - cv.wait(l, [&]{ return !!ret; }); // predicate is to deal with spurious wakeups return ret; } diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 6593ac297..505428662 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -105,7 +105,7 @@ void VideoContext::Reset() { // Remove provider provider.reset(); - video_provider = 0; + video_provider = nullptr; keyframes.clear(); keyframes_filename.clear();