Improve hints dialog in various ways, especially with long projects (#1439).
authorCarl Hetherington <cth@carlh.net>
Sun, 6 Jan 2019 19:49:37 +0000 (19:49 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 6 Jan 2019 19:49:37 +0000 (19:49 +0000)
ChangeLog
src/lib/hints.cc
src/lib/hints.h
src/wx/hints_dialog.cc
src/wx/hints_dialog.h

index 1f87ca82e4374e4df5bca8387057673e7ecb58a1..6b4528edba87d479683429c9be89819ed31b780a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2019-01-06  Carl Hetherington  <cth@carlh.net>
 
+       * Improve behaviour of hints dialog with long projects (#1439).
+
        * Fix incorrect video waveform display (#1425).
 
 2019-01-05  Carl Hetherington  <cth@carlh.net>
index 185626983ac171538f24cfcbb4f87edcdc7f0e41..d961b1a3022eef80240db344623b3760064b3555 100644 (file)
@@ -56,6 +56,7 @@ Hints::Hints (weak_ptr<const Film> 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)));
index b8bc806c010f8cb103d84d25931f0f06218ba40d..35e3618421df8be4b9489c1ca1e5a1b192ed9477 100644 (file)
@@ -56,4 +56,7 @@ private:
        bool _overlap_ccap;
        bool _too_many_ccap_lines;
        boost::optional<DCPTimePeriod> _last;
+
+       boost::mutex _mutex;
+       bool _stop;
 };
index 099b31327f8a6d7ab46c068aad5e1c0c2c3b3ee3..18e8a6f9eb1cea6e3e7ddc87d5ad52532ada9c99 100644 (file)
@@ -41,6 +41,7 @@ HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> film, bool ok)
        : wxDialog (parent, wxID_ANY, _("Hints"))
        , _film (film)
        , _hints (new Hints (film))
+       , _finished (false)
 {
        wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
 
@@ -109,6 +110,7 @@ HintsDialog::film_change (ChangeType type)
        Layout ();
        _gauge->SetValue (0);
        update ();
+       _finished = false;
        _hints->start ();
 }
 
@@ -123,7 +125,11 @@ HintsDialog::update ()
 {
        _text->Clear ();
        if (_current.empty ()) {
-               _text->WriteText (_("There are no hints: everything looks good!"));
+               if (_finished) {
+                       _text->WriteText (_("There are no hints: everything looks good!"));
+               } else {
+                       _text->WriteText (_("There are no hints yet: project check in progress."));
+               }
        } else {
                _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
                BOOST_FOREACH (string i, _current) {
@@ -156,6 +162,8 @@ HintsDialog::pulse ()
 void
 HintsDialog::finished ()
 {
+       _finished = true;
+       update ();
        _gauge->Hide ();
        _gauge_message->Hide ();
        Layout ();
index 2755c70fdf8f8f9c47b9a6e047a3828dc8f5d2b4..709587ac9dcd6ecb38d4ab0f45ef3da1599bb3a2 100644 (file)
@@ -48,6 +48,7 @@ private:
        wxRichTextCtrl* _text;
        boost::shared_ptr<Hints> _hints;
        std::list<std::string> _current;
+       bool _finished;
 
        boost::signals2::scoped_connection _film_change_connection;
        boost::signals2::scoped_connection _film_content_change_connection;