X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftools%2Fdcpomatic_batch.cc;h=3114768aca497c5f03bd8ebc4845b239ffb6b2b9;hb=72d906fe6e30eff1324288748fc5d1d66b3a3ec1;hp=a2db604df15ebfae89d92fd66cac4730cfd450cd;hpb=18bb22e82336c76351eb0f8b57a0b5a1cffb2e5c;p=dcpomatic.git diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index a2db604df..3114768ac 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" @@ -36,6 +37,7 @@ #include "lib/transcode_job.h" #include "lib/util.h" #include "lib/version.h" +#include #include LIBDCP_DISABLE_WARNINGS #include @@ -128,7 +130,7 @@ public: if (filenames.GetCount() == 1) { /* Try to load a directory */ auto path = boost::filesystem::path(wx_to_std(filenames[0])); - if (boost::filesystem::is_directory(path)) { + if (dcp::filesystem::is_directory(path)) { _frame->start_job(wx_to_std(filenames[0])); return true; } @@ -268,16 +270,14 @@ 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 ); - bool const r = d->ShowModal() == wxID_YES; - d->Destroy (); - return r; + return d->ShowModal() == wxID_YES; } void close (wxCloseEvent& ev) @@ -321,22 +321,21 @@ private: void help_about () { - auto d = new AboutDialog (this); + auto d = make_wx(this); d->ShowModal (); - d->Destroy (); } void add_film () { - auto c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + auto dialog = make_wx(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); if (_last_parent) { - c->SetPath (std_to_wx(_last_parent.get().string())); + dialog->SetPath(std_to_wx(_last_parent.get().string())); } int r; while (true) { - r = c->ShowModal (); - if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { + r = dialog->ShowModal(); + if (r == wxID_OK && dialog->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open.")); } else { break; @@ -344,12 +343,10 @@ private: } if (r == wxID_OK) { - start_job (wx_to_std (c->GetPath ())); + start_job(wx_to_std(dialog->GetPath())); } - _last_parent = boost::filesystem::path (wx_to_std (c->GetPath ())).parent_path (); - - c->Destroy (); + _last_parent = boost::filesystem::path(wx_to_std(dialog->GetPath())).parent_path(); } void config_changed (Config::Property what) @@ -395,30 +392,30 @@ 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 { try { - int const length = socket->read_uint32 (); - scoped_array buffer(new char[length]); - socket->read (reinterpret_cast(buffer.get()), length); - string s (buffer.get()); - _frame->start_job (s); - socket->write (reinterpret_cast("OK"), 3); + auto const length = socket->read_uint32(); + if (length < 65536) { + scoped_array buffer(new char[length]); + socket->read(reinterpret_cast(buffer.get()), length); + string s(buffer.get()); + emit(boost::bind(boost::ref(StartJob), s)); + socket->write (reinterpret_cast("OK"), 3); + } } catch (...) { } } -private: - DOMFrame* _frame; + boost::signals2::signal StartJob; }; @@ -473,7 +470,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.")); @@ -484,7 +482,7 @@ class App : public wxApp shared_ptr film; for (auto i: films_to_load) { - if (boost::filesystem::is_directory(i)) { + if (dcp::filesystem::is_directory(i)) { try { film = make_shared(i); film->read_metadata ();