From d43434e463f5ef76ee448046ffb09ffe4b05ea8d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 6 Jan 2019 19:49:37 +0000 Subject: Improve hints dialog in various ways, especially with long projects (#1439). --- src/lib/hints.cc | 26 ++++++++++++++++++++++++-- src/lib/hints.h | 3 +++ 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 185626983..d961b1a30 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -56,6 +56,7 @@ Hints::Hints (weak_ptr film) , _long_ccap (false) , _overlap_ccap (false) , _too_many_ccap_lines (false) + , _stop (false) { } @@ -65,6 +66,10 @@ Hints::stop_thread () { if (_thread) { try { + { + boost::mutex::scoped_lock lm (_mutex); + _stop = true; + } _thread->interrupt (); _thread->join (); } catch (...) { @@ -88,6 +93,7 @@ Hints::start () _long_ccap = false; _overlap_ccap = false; _too_many_ccap_lines = false; + _stop = false; _thread = new boost::thread (bind(&Hints::thread, this)); } @@ -267,8 +273,24 @@ Hints::thread () player->set_ignore_video (); player->set_ignore_audio (); player->Text.connect (bind(&Hints::text, this, _1, _2, _4)); - while (!player->pass ()) { - bind (boost::ref(Pulse)); + + struct timeval last_pulse; + gettimeofday (&last_pulse, 0); + + while (!player->pass()) { + + struct timeval now; + gettimeofday (&now, 0); + if ((seconds(now) - seconds(last_pulse)) > 1) { + { + boost::mutex::scoped_lock lm (_mutex); + if (_stop) { + break; + } + } + emit (bind (boost::ref(Pulse))); + last_pulse = now; + } } emit (bind(boost::ref(Finished))); diff --git a/src/lib/hints.h b/src/lib/hints.h index b8bc806c0..35e361842 100644 --- a/src/lib/hints.h +++ b/src/lib/hints.h @@ -56,4 +56,7 @@ private: bool _overlap_ccap; bool _too_many_ccap_lines; boost::optional _last; + + boost::mutex _mutex; + bool _stop; }; -- cgit v1.2.3