swaroop: fix decrementing of allowed shows count to be at the right time.
[dcpomatic.git] / src / wx / closed_captions_dialog.cc
index 8e007c38fcae29daf93438cd986c6f49b00c0d10..061262cddcc96eff127cac8dfcf5b8661e587f77 100644 (file)
@@ -35,6 +35,7 @@ using std::make_pair;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::optional;
+using namespace dcpomatic;
 
 ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer)
        : wxDialog (parent, wxID_ANY, _("Closed captions"), wxDefaultPosition, wxDefaultSize,
@@ -148,10 +149,11 @@ ClosedCaptionsDialog::update (DCPTime time)
                _current = optional<TextRingBuffers::Data>();
        }
 
-       if (!_current) {
+       if (!_current && !_tracks.empty()) {
                /* We have no current one: get another */
                shared_ptr<Butler> butler = _butler.lock ();
                DCPOMATIC_ASSERT (butler);
+               DCPOMATIC_ASSERT (_track->GetSelection() >= 0);
                DCPOMATIC_ASSERT (_track->GetSelection() < int(_tracks.size()));
                DCPTextTrack track = _tracks[_track->GetSelection()];
                while (true) {