X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_server.cc;h=8107949f5a9a4950e5661c728bc57eec15c74970;hb=0f7110dc6a34640a55ba5bdc16dd23f2b9f47d30;hp=8c6a294619bed2230357fc4124bb6f317093025f;hpb=2fabfde079641001d0968ca2fee8e70a0b929e27;p=dcpomatic.git diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc index 8c6a29461..8107949f5 100644 --- a/src/tools/dcpomatic_server.cc +++ b/src/tools/dcpomatic_server.cc @@ -27,6 +27,7 @@ using std::cout; using std::string; +using std::exception; using boost::shared_ptr; using boost::thread; using boost::bind; @@ -46,6 +47,14 @@ public: return _log; } + string head_and_tail (int amount = 1024) const { + if (int (_log.size ()) < (2 * amount)) { + return _log; + } + + return _log.substr (0, amount) + _log.substr (_log.size() - amount - 1, amount); + } + private: void do_log (string m) { @@ -99,7 +108,7 @@ public: #endif #ifdef __WXGTK__ wxInitAllImageHandlers(); - wxBitmap bitmap (wxString::Format (wxT ("%s/taskbar_icon.png"), POSIX_ICON_PREFIX), wxBITMAP_TYPE_PNG); + wxBitmap bitmap (wxString::Format (wxT ("%s/taskbar_icon.png"), LINUX_SHARE_PREFIX), wxBITMAP_TYPE_PNG); wxIcon icon; icon.CopyFromBitmap (bitmap); #endif @@ -133,7 +142,7 @@ private: } }; -class App : public wxApp +class App : public wxApp, public ExceptionStore { public: App () @@ -154,6 +163,10 @@ private: _icon = new TaskBarIcon; _thread = new thread (bind (&App::main_thread, this)); + + Bind (wxEVT_TIMER, boost::bind (&App::check, this)); + _timer.reset (new wxTimer (this)); + _timer->Start (1000); return true; } @@ -165,13 +178,29 @@ private: } void main_thread () - { + try { Server server (memory_log, false); server.run (Config::instance()->num_local_encoding_threads ()); + } catch (...) { + store_current (); + } + + void check () + { + try { + rethrow (); + } catch (exception& e) { + error_dialog (0, std_to_wx (e.what ())); + wxTheApp->ExitMainLoop (); + } catch (...) { + error_dialog (0, _("An unknown error has occurred with the DCP-o-matic server.")); + wxTheApp->ExitMainLoop (); + } } boost::thread* _thread; TaskBarIcon* _icon; + shared_ptr _timer; }; IMPLEMENT_APP (App)