Fix double-appearance of subtitle colour controls.
authorCarl Hetherington <cth@carlh.net>
Sat, 26 Jan 2019 19:58:56 +0000 (19:58 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 26 Jan 2019 19:58:56 +0000 (19:58 +0000)
src/wx/subtitle_appearance_dialog.cc
src/wx/subtitle_appearance_dialog.h

index 339388be6e14e0eb25141f2efc8a49ea358599f3..ad4c038503b1e25567e0baa8b8a03a49ef334284 100644 (file)
@@ -58,7 +58,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
                /* XXX: assuming that all FFmpeg streams have bitmap subs */
                if (_stream->colours().empty()) {
                        _job_manager_connection = JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&SubtitleAppearanceDialog::active_jobs_changed, this, _1));
-                       JobManager::instance()->add(shared_ptr<Job>(new ExamineFFmpegSubtitlesJob(film, ff)));
+                       _job = JobManager::instance()->add(shared_ptr<Job>(new ExamineFFmpegSubtitlesJob(film, ff)));
                }
        }
 
@@ -107,7 +107,10 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
                t->SetLabelMarkup (_("<b>New colour</b>"));
                _colour_table->Add (t, 1, wxALIGN_CENTER);
 
-               add_colours ();
+               shared_ptr<Job> job = _job.lock ();
+               if (!job || job->finished()) {
+                       add_colours ();
+               }
 
                _colours_panel->SetSizer (_colour_table);
 
index ed0360e4c281ba95c021cfbee731e1ef75b0fce1..0b3c661326c95feb81b9800f643b6f9c8e35b508 100644 (file)
@@ -33,6 +33,7 @@ class FFmpegSubtitleStream;
 class wxCheckBox;
 class wxWidget;
 class Film;
+class Job;
 
 class SubtitleAppearanceDialog : public wxDialog
 {
@@ -76,6 +77,8 @@ private:
        boost::signals2::scoped_connection _content_connection;
        boost::signals2::scoped_connection _job_manager_connection;
 
+       boost::weak_ptr<Job> _job;
+
        static int const NONE;
        static int const OUTLINE;
        static int const SHADOW;