X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_batch.cc;h=24897dfba1aaa993f8819a6fc9a7b0b8a018320e;hb=863569363d596ca6d76a918f10ee3bec748a0b25;hp=64015a0e30179faa7a0dd7b78bf05a2109dc2e21;hpb=b7e65adf286ce20918797a06a910ededf8f07b7b;p=dcpomatic.git diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 64015a0e3..24897dfba 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -24,6 +24,7 @@ #include "wx/full_config_dialog.h" #include "wx/job_manager_view.h" #include "wx/servers_list_dialog.h" +#include "wx/wx_ptr.h" #include "wx/wx_signal_manager.h" #include "wx/wx_util.h" #include "lib/compose.hpp" @@ -33,7 +34,6 @@ #include "lib/job.h" #include "lib/job_manager.h" #include "lib/make_dcp.h" -#include "lib/scope_guard.h" #include "lib/transcode_job.h" #include "lib/util.h" #include "lib/version.h" @@ -269,13 +269,12 @@ private: return true; } - auto d = new wxMessageDialog ( - 0, + auto d = make_wx( + nullptr, _("There are unfinished jobs; are you sure you want to quit?"), _("Unfinished jobs"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION ); - ScopeGuard sg = [d]{ d->Destroy(); }; return d->ShowModal() == wxID_YES; } @@ -321,15 +320,13 @@ private: void help_about () { - auto d = new AboutDialog (this); - ScopeGuard sg = [d]() { d->Destroy(); }; + auto d = make_wx(this); d->ShowModal (); } void add_film () { - auto dialog = new wxDirDialog(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); - ScopeGuard sg = [dialog]() { dialog->Destroy(); }; + auto dialog = make_wx(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); if (_last_parent) { dialog->SetPath(std_to_wx(_last_parent.get().string())); } @@ -394,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 @@ -409,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; }; @@ -472,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."));