summaryrefslogtreecommitdiff
path: root/src/tools/dcpomatic_server.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-12-31 15:44:51 +0000
committerCarl Hetherington <cth@carlh.net>2013-12-31 15:44:51 +0000
commitad49361b303d1ceff7048fa0e89ba609ca9ce376 (patch)
treebe6413325604b0d403add54a8de6ea861ec90772 /src/tools/dcpomatic_server.cc
parentb2a9271256e09fcfedff3beea5fc73c04e7c0e14 (diff)
parent5625ba9542e38504e87799dd655be5071161fb1f (diff)
Merge 1.0
Diffstat (limited to 'src/tools/dcpomatic_server.cc')
-rw-r--r--src/tools/dcpomatic_server.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc
index 8c6a29461..a82478dfd 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;
@@ -133,7 +134,7 @@ private:
}
};
-class App : public wxApp
+class App : public wxApp, public ExceptionStore
{
public:
App ()
@@ -154,6 +155,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 +170,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<wxTimer> _timer;
};
IMPLEMENT_APP (App)