diff --git a/mapeditor/mapcontroller.h b/mapeditor/mapcontroller.h index 55235f05f..0fdc4025d 100644 --- a/mapeditor/mapcontroller.h +++ b/mapeditor/mapcontroller.h @@ -69,6 +69,7 @@ public: void redo(); PlayerColor defaultPlayer; + QDialog * settingsDialog = nullptr; private: std::unique_ptr _map; diff --git a/mapeditor/mapsettings/loseconditions.cpp b/mapeditor/mapsettings/loseconditions.cpp index e7b559438..375b41108 100644 --- a/mapeditor/mapsettings/loseconditions.cpp +++ b/mapeditor/mapsettings/loseconditions.cpp @@ -310,12 +310,12 @@ void LoseConditions::onObjectSelect() QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &LoseConditions::onObjectPicked); } - dynamic_cast(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide(); + controller->settingsDialog->hide(); } void LoseConditions::onObjectPicked(const CGObjectInstance * obj) { - dynamic_cast(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show(); + controller->settingsDialog->show(); for(int lvl : {0, 1}) { diff --git a/mapeditor/mapsettings/mapsettings.cpp b/mapeditor/mapsettings/mapsettings.cpp index f94783020..6f7da223b 100644 --- a/mapeditor/mapsettings/mapsettings.cpp +++ b/mapeditor/mapsettings/mapsettings.cpp @@ -27,7 +27,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) : ui->setupUi(this); assert(controller.map()); - + controller.settingsDialog = this; show(); for(auto const & objectPtr : VLC->skillh->objects) @@ -73,6 +73,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) : MapSettings::~MapSettings() { + controller.settingsDialog = nullptr; delete ui; } diff --git a/mapeditor/mapsettings/timedevent.cpp b/mapeditor/mapsettings/timedevent.cpp index 39b983295..81998765f 100644 --- a/mapeditor/mapsettings/timedevent.cpp +++ b/mapeditor/mapsettings/timedevent.cpp @@ -122,7 +122,7 @@ void TimedEvent::on_addObjectToDelete_clicked() QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &TimedEvent::onObjectPicked); } hide(); - dynamic_cast(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide(); + controller.settingsDialog->hide(); } void TimedEvent::on_removeObjectToDelete_clicked() @@ -133,7 +133,7 @@ void TimedEvent::on_removeObjectToDelete_clicked() void TimedEvent::onObjectPicked(const CGObjectInstance * obj) { show(); - dynamic_cast(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show(); + controller.settingsDialog->show(); for(int lvl : {0, 1}) { diff --git a/mapeditor/mapsettings/victoryconditions.cpp b/mapeditor/mapsettings/victoryconditions.cpp index 78d7335a8..f590af797 100644 --- a/mapeditor/mapsettings/victoryconditions.cpp +++ b/mapeditor/mapsettings/victoryconditions.cpp @@ -528,12 +528,12 @@ void VictoryConditions::onObjectSelect() QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &VictoryConditions::onObjectPicked); } - dynamic_cast(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide(); + controller->settingsDialog->hide(); } void VictoryConditions::onObjectPicked(const CGObjectInstance * obj) { - dynamic_cast(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show(); + controller->settingsDialog->show(); for(int lvl : {0, 1}) { diff --git a/mapeditor/playerparams.cpp b/mapeditor/playerparams.cpp index 985c01d47..294c5c444 100644 --- a/mapeditor/playerparams.cpp +++ b/mapeditor/playerparams.cpp @@ -202,12 +202,12 @@ void PlayerParams::on_townSelect_clicked() QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &PlayerParams::onTownPicked); } - dynamic_cast(parent()->parent()->parent()->parent())->hide(); + controller.settingsDialog->hide(); } void PlayerParams::onTownPicked(const CGObjectInstance * obj) { - dynamic_cast(parent()->parent()->parent()->parent())->show(); + controller.settingsDialog->show(); for(int lvl : {0, 1}) { diff --git a/mapeditor/playersettings.cpp b/mapeditor/playersettings.cpp index 9c5fa89c2..ef4a382c2 100644 --- a/mapeditor/playersettings.cpp +++ b/mapeditor/playersettings.cpp @@ -22,6 +22,7 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) : controller(ctrl) { ui->setupUi(this); + controller.settingsDialog = this; show(); int players = 0; @@ -46,6 +47,7 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) : PlayerSettings::~PlayerSettings() { + controller.settingsDialog = nullptr; delete ui; }