From: Carl Hetherington Date: Fri, 9 Jun 2023 21:18:55 +0000 (+0200) Subject: Don't call DOMFrame::start_job from a non-UI thread. X-Git-Tag: v2.16.60~35 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=2a7873ffae6e6579b9d794f9f2cd07e07e906a4e;p=dcpomatic.git Don't call DOMFrame::start_job from a non-UI thread. --- diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index b73d0a418..24897dfba 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -391,12 +391,11 @@ static const wxCmdLineEntryDesc command_line_description[] = { }; -class JobServer : public Server +class JobServer : public Server, public Signaller { public: - explicit JobServer (DOMFrame* frame) + JobServer() : Server (BATCH_JOB_PORT) - , _frame (frame) {} void handle (shared_ptr socket) override @@ -406,15 +405,14 @@ public: scoped_array buffer(new char[length]); socket->read (reinterpret_cast(buffer.get()), length); string s (buffer.get()); - _frame->start_job (s); + emit(boost::bind(boost::ref(StartJob), s)); socket->write (reinterpret_cast("OK"), 3); } catch (...) { } } -private: - DOMFrame* _frame; + boost::signals2::signal StartJob; }; @@ -469,7 +467,8 @@ class App : public wxApp _frame->Show (); try { - auto server = new JobServer (_frame); + auto server = new JobServer(); + server->StartJob.connect(bind(&DOMFrame::start_job, _frame, _1)); new thread (boost::bind (&JobServer::run, server)); } catch (boost::system::system_error& e) { error_dialog(_frame, _("Could not listen for new batch jobs. Perhaps another instance of the DCP-o-matic Batch Converter is running."));