- if (d->ShowModal () == wxID_OK) {
- s.second->name = d->name ();
- s.second->notes = d->notes ();
- s.second->recipient = d->recipient ();
- s.second->trusted_devices = d->trusted_devices ();
- _targets->SetItemText (s.first, std_to_wx (d->name()));
- Config::instance()->changed ();
+ if (d->ShowModal () != wxID_OK) {
+ d->Destroy ();
+ return;
+ }
+
+ shared_ptr<Cinema> c = s.second->cinema;
+ BOOST_FOREACH (shared_ptr<Screen> i, c->screens ()) {
+ if (i != s.second && i->name == d->name()) {
+ error_dialog (
+ GetParent(),
+ wxString::Format (
+ _("You cannot change this screen's name to '%s' as the cinema already has a screen with this name."),
+ std_to_wx(d->name()).data()
+ )
+ );
+ return;
+ }