C++11 tidying.
[dcpomatic.git] / src / tools / dcpomatic_disk.cc
index 81db2dd0a473c49361fe948fa05153ec510f4a56..a3b351c85fdc5d28ea11d575b5ead69879b0ef5f 100644 (file)
 */
 
 
-#include "wx/wx_signal_manager.h"
-#include "wx/wx_util.h"
-#include "wx/job_manager_view.h"
+#include "wx/disk_warning_dialog.h"
 #include "wx/drive_wipe_warning_dialog.h"
-#include "wx/try_unmount_dialog.h"
+#include "wx/job_manager_view.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"
+#include "wx/try_unmount_dialog.h"
+#include "wx/wx_util.h"
+#include "wx/wx_signal_manager.h"
+#include "wx/wx_util.h"
 #include "lib/config.h"
-#include "lib/signal_manager.h"
-#include "lib/cross.h"
 #include "lib/copy_to_drive_job.h"
-#include "lib/job_manager.h"
+#include "lib/cross.h"
+#include "lib/dcpomatic_log.h"
 #include "lib/disk_writer_messages.h"
+#include "lib/file_log.h"
+#include "lib/job_manager.h"
+#include "lib/signal_manager.h"
+#include "lib/util.h"
 #include "lib/version.h"
 #include "lib/warnings.h"
 #include <wx/wx.h>
@@ -49,11 +50,12 @@ DCPOMATIC_ENABLE_WARNINGS
 #endif
 
 
-using std::string;
-using std::exception;
-using std::cout;
 using std::cerr;
+using std::cout;
+using std::exception;
+using std::make_shared;
 using std::shared_ptr;
+using std::string;
 using boost::optional;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
@@ -237,6 +239,13 @@ private:
 
        void copy ()
        {
+               /* Check that the selected drive still exists and update its properties if so */
+               drive_refresh ();
+               if (_drive->GetSelection() == wxNOT_FOUND) {
+                       error_dialog (this, _("The disk you selected is no longer available.  Please choose another."));
+                       return;
+               }
+
                DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND);
                DCPOMATIC_ASSERT (static_cast<bool>(_dcp_path));
 
@@ -281,7 +290,8 @@ private:
                        if (!_nanomsg.send(drive.as_xml(), 2000)) {
                                throw CommunicationFailedError ();
                        }
-                       auto <string> reply = _nanomsg.receive (2000);
+                       /* The reply may have to wait for the user to authenticate, so let's wait a while */
+                       auto reply = _nanomsg.receive (30000);
                        if (!reply || *reply != DISK_WRITER_OK) {
                                auto * m = new MessageDialog (
                                                this,
@@ -320,7 +330,7 @@ private:
                int j = 0;
                _drives = Drive::get ();
                for (auto i: _drives) {
-                       auto const s = std_to_wx(i.description();
+                       auto const s = std_to_wx(i.description());
                        if (s == current) {
                                re_select = j;
                        }