X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_disk.cc;h=28799013f700f5e643abf455b83c2e191f4dd933;hb=c7d40367c36c7bf7586d70c06b437010e2b9d5ec;hp=e2cd108c17a4654d6942245aed1d723f66662d4c;hpb=2d6dc3ab7212316bc297b7fceea27d12187a6c06;p=dcpomatic.git diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index e2cd108c1..28799013f 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -249,16 +249,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; } @@ -286,11 +284,11 @@ private: auto ping = [this](int attempt) { if (_nanomsg.send(DISK_WRITER_PING "\n", 1000)) { - auto reply = _nanomsg.receive (1000); - if (reply && *reply == DISK_WRITER_PONG) { + auto reply = DiskWriterBackEndResponse::read_from_nanomsg(_nanomsg, 1000); + if (reply && reply->type() == DiskWriterBackEndResponse::Type::PONG) { return true; } else if (reply) { - LOG_DISK("Unexpected response %1 to ping received (attempt %2)", *reply, attempt); + LOG_DISK("Unexpected response %1 to ping received (attempt %2)", static_cast(reply->type()), attempt); } else { LOG_DISK("No reply received from ping (attempt %1)", attempt); } @@ -311,22 +309,20 @@ private: if (!have_writer) { #if defined(DCPOMATIC_WINDOWS) - auto m = new MessageDialog ( + auto m = make_wx( this, _("DCP-o-matic Disk Writer"), _("Do you see a 'User Account Control' dialogue asking about dcpomatic2_disk_writer.exe? If so, click 'Yes', then try again.") ); m->ShowModal (); - m->Destroy (); return; #elif defined(DCPOMATIC_OSX) - auto m = new MessageDialog ( + auto m = make_wx( this, _("DCP-o-matic Disk Writer"), _("Did you install the DCP-o-matic Disk Writer.pkg from the .dmg? Please check and try again.") ); m->ShowModal (); - m->Destroy (); return; #else LOG_DISK_NC ("Failed to ping writer"); @@ -336,9 +332,8 @@ private: auto const& drive = _drives[_drive->GetSelection()]; if (drive.mounted()) { - auto d = new TryUnmountDialog(this, drive.description()); + auto d = make_wx(this, drive.description()); int const r = d->ShowModal (); - d->Destroy (); if (r != wxID_OK) { return; } @@ -353,26 +348,29 @@ private: throw CommunicationFailedError (); } /* 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 ( + auto const reply = DiskWriterBackEndResponse::read_from_nanomsg(_nanomsg, 30000); + if (!reply || reply->type() != DiskWriterBackEndResponse::Type::OK) { + auto m = make_wx( this, _("DCP-o-matic Disk Writer"), - wxString::Format(_("The drive %s could not be unmounted.\nClose any application that is using it, then try again."), std_to_wx(drive.description())) + wxString::Format( + _("The drive %s could not be unmounted.\nClose any application that is using it, then try again. (%s)"), + std_to_wx(drive.description()), + reply->error_message() + ) ); m->ShowModal (); - m->Destroy (); return; } } - auto * d = new DriveWipeWarningDialog (this, _drive->GetString(_drive->GetSelection())); - int const r = d->ShowModal (); - bool ok = r == wxID_OK && d->confirmed(); - d->Destroy (); - - if (!ok) { + auto d = make_wx(this, _drive->GetString(_drive->GetSelection())); + if (d->ShowModal() != wxID_OK) { + return; + } + if (!d->confirmed()) { + message_dialog(this, _("You did not correctly confirm that you read the warning that was just shown. Please try again.")); return; } @@ -478,12 +476,14 @@ public: Config::drop (); if (!_skip_alpha_check) { - auto warning = new DiskWarningDialog (); - warning->ShowModal (); + auto warning = make_wx(); + if (warning->ShowModal() != wxID_OK) { + return false; + } if (!warning->confirmed()) { + message_dialog(nullptr, _("You did not correctly confirm that you read the warning that was just shown. DCP-o-matic Disk Writer will close now. Please try again.")); return false; } - warning->Destroy (); } _frame = new DOMFrame (_("DCP-o-matic Disk Writer"));