X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_disk.cc;h=6f72bfed0e749b672e5d1208afb560b3fbbfa3f7;hb=3ee6f2e6ee3682fd1eebfd15c2d61588587e7096;hp=ba92cf94e808cbb4133fc2eadabfddecf5c655fe;hpb=06d773174378a70289bee8d7abb62e67deaaddf8;p=dcpomatic.git diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index ba92cf94e..6f72bfed0 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -24,6 +24,7 @@ #include "wx/drive_wipe_warning_dialog.h" #include "wx/try_unmount_dialog.h" #include "wx/message_dialog.h" +#include "wx/disk_warning_dialog.h" #include "lib/file_log.h" #include "lib/dcpomatic_log.h" #include "lib/util.h" @@ -33,6 +34,7 @@ #include "lib/copy_to_drive_job.h" #include "lib/job_manager.h" #include "lib/disk_writer_messages.h" +#include "lib/version.h" #include #include #ifdef DCPOMATIC_WINDOWS @@ -111,7 +113,7 @@ public: */ dcpomatic_log.reset(new FileLog(config_path() / "disk.log")); dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DISK); - LOG_DISK_NC("dcpomatic_disk started"); + LOG_DISK("dcpomatic_disk %1 started", dcpomatic_git_commit); drive_refresh (); @@ -175,10 +177,11 @@ private: return; } + LOG_DISK("Sending unmount request to disk writer for %1", drive.as_xml()); if (!_nanomsg.send(DISK_WRITER_UNMOUNT "\n", 2000)) { throw CommunicationFailedError (); } - if (!_nanomsg.send(drive.internal_name() + "\n", 2000)) { + if (!_nanomsg.send(drive.as_xml(), 2000)) { throw CommunicationFailedError (); } optional reply = _nanomsg.receive (2000); @@ -194,7 +197,7 @@ private: } } - + DriveWipeWarningDialog* d = new DriveWipeWarningDialog (this, _drive->GetString(_drive->GetSelection())); int const r = d->ShowModal (); bool ok = r == wxID_OK && d->confirmed(); @@ -218,7 +221,7 @@ private: _drive->Clear (); int re_select = wxNOT_FOUND; int j = 0; - _drives = get_drives (); + _drives = Drive::get (); BOOST_FOREACH (Drive i, _drives) { wxString const s = std_to_wx(i.description()); if (s == current) { @@ -244,7 +247,9 @@ private: JobManagerView* _jobs; boost::optional _dcp_path; std::vector _drives; +#ifndef DCPOMATIC_OSX boost::process::child* _writer; +#endif Nanomsg _nanomsg; wxSizer* _sizer; }; @@ -298,6 +303,12 @@ public: */ Config::drop (); + DiskWarningDialog* warning = new DiskWarningDialog (); + warning->ShowModal (); + if (!warning->confirmed()) { + return false; + } + _frame = new DOMFrame (_("DCP-o-matic Disk Writer")); SetTopWindow (_frame); @@ -309,6 +320,7 @@ public: catch (exception& e) { error_dialog (0, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what())); + return false; } return true; @@ -330,6 +342,44 @@ public: ev.Skip (); } + void report_exception () + { + try { + throw; + } catch (FileError& e) { + error_dialog ( + 0, + wxString::Format ( + _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM, + std_to_wx (e.what()), + std_to_wx (e.file().string().c_str ()) + ) + ); + } catch (exception& e) { + error_dialog ( + 0, + wxString::Format ( + _("An exception occurred: %s.\n\n") + REPORT_PROBLEM, + std_to_wx (e.what ()) + ) + ); + } catch (...) { + error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); + } + } + + bool OnExceptionInMainLoop () + { + report_exception (); + /* This will terminate the program */ + return false; + } + + void OnUnhandledException () + { + report_exception (); + } + DOMFrame* _frame; };