Build fixes related to simple/GL view.
[dcpomatic.git] / src / tools / dcpomatic_player.cc
index 1cc53dafba2f6cf9aa95c52e39208f8576dab7dd..3ba63379bbbecb820c3ad30fd82aeff1fa4fff13 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2017-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2017-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -29,6 +29,7 @@
 #include "wx/verify_dcp_dialog.h"
 #include "wx/standard_controls.h"
 #include "wx/swaroop_controls.h"
+#include "wx/timer_display.h"
 #include "lib/cross.h"
 #include "lib/config.h"
 #include "lib/util.h"
@@ -88,6 +89,7 @@ using boost::optional;
 using boost::dynamic_pointer_cast;
 using boost::thread;
 using boost::bind;
+using namespace dcpomatic;
 
 enum {
        ID_file_open = 1,
@@ -108,6 +110,7 @@ enum {
        ID_help_report_a_problem,
        ID_tools_verify,
        ID_tools_check_for_updates,
+       ID_tools_timing,
        /* IDs for shortcuts (with no associated menu item) */
        ID_start_stop,
        ID_back_frame,
@@ -168,6 +171,7 @@ public:
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_verify, this), ID_tools_verify);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_check_for_updates, this), ID_tools_check_for_updates);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_timing, this), ID_tools_timing);
 
                /* Use a panel as the only child of the Frame so that we avoid
                   the dark-grey background on Windows.
@@ -289,6 +293,9 @@ public:
        void playback_started (DCPTime time)
        {
                /* XXX: this only logs the first piece of content; probably should be each piece? */
+               if (_film->content().empty()) {
+                       return;
+               }
 
                shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent>(_film->content().front());
                if (dcp) {
@@ -495,6 +502,7 @@ private:
                _tools_verify = tools->Append (ID_tools_verify, _("Verify DCP"));
                tools->AppendSeparator ();
                tools->Append (ID_tools_check_for_updates, _("Check for updates"));
+               tools->Append (ID_tools_timing, _("Timing..."));
 
                wxMenu* help = new wxMenu;
 #ifdef __WXOSX__
@@ -612,7 +620,11 @@ private:
                vector<boost::filesystem::path> history = Config::instance()->player_history ();
                int n = event.GetId() - ID_file_history;
                if (n >= 0 && n < static_cast<int> (history.size ())) {
-                       load_dcp (history[n]);
+                       try {
+                               load_dcp (history[n]);
+                       } catch (exception& e) {
+                               error_dialog (0, std_to_wx(String::compose(wx_to_std(_("Could not load DCP %1.")), history[n])), std_to_wx(e.what()));
+                       }
                }
        }
 
@@ -761,6 +773,13 @@ private:
                _update_news_requested = true;
        }
 
+       void tools_timing ()
+       {
+               TimerDisplay* d = new TimerDisplay (this, _viewer->state_timer(), _viewer->gets());
+               d->ShowModal ();
+               d->Destroy ();
+       }
+
        void help_about ()
        {
                AboutDialog* d = new AboutDialog (this);
@@ -844,6 +863,8 @@ private:
 
                int pos = _history_position;
 
+               /* Clear out non-existant history items before we re-build the menu */
+               Config::instance()->clean_player_history ();
                vector<boost::filesystem::path> history = Config::instance()->player_history ();
 
                if (!history.empty ()) {
@@ -869,7 +890,7 @@ private:
                        } else {
                                dcpomatic_log.reset (new NullLog());
                        }
-                       dcpomatic_log->set_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR);
+                       dcpomatic_log->set_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR | LogEntry::TYPE_DEBUG_PLAYER);
                }
        }