+ /* Try to decrypt it to get an early preview of any errors */
+ try {
+ decrypt_kdm_with_helpful_error (*kdm);
+ } catch (KDMError& e) {
+ error_dialog (_parent, std_to_wx(e.summary()), std_to_wx(e.detail()));
+ return;
+ } catch (exception& e) {
+ error_dialog (_parent, e.what());
+ return;
+ }
+
+ DCPExaminer ex (dcp, true);
+
+ bool kdm_matches_any_cpl = false;
+ for (auto i: ex.cpls()) {
+ if (i->id() == kdm->cpl_id()) {
+ kdm_matches_any_cpl = true;
+ }
+ }
+
+ bool kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
+
+ if (!kdm_matches_any_cpl) {
+ error_dialog (_parent, _("This KDM was not made for this DCP. You will need a different one."));
+ return;
+ }
+
+ if (!kdm_matches_selected_cpl && kdm_matches_any_cpl) {
+ message_dialog (_parent, _("This KDM was made for one of the CPLs in this DCP, but not the currently selected one. To play the currently-selected CPL you will need a different KDM."));
+ }
+
+ dcp->add_kdm (*kdm);
+
+ auto film = _film.lock ();