Skip to content

Commit 3900faa

Browse files
authored
Fix issue where QtFred could have multiple Ship Dialogs open (scp-fs2open#6909)
1 parent 5cd3b3a commit 3900faa

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

qtfred/src/ui/FredView.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,18 @@ void FredView::on_actionWaypoint_Paths_triggered(bool) {
743743
}
744744
void FredView::on_actionShips_triggered(bool)
745745
{
746-
auto editorDialog = new dialogs::ShipEditorDialog(this, _viewport);
747-
editorDialog->setAttribute(Qt::WA_DeleteOnClose);
748-
editorDialog->show();
746+
if (!_shipEditorDialog) {
747+
_shipEditorDialog = new dialogs::ShipEditorDialog(this, _viewport);
748+
_shipEditorDialog->setAttribute(Qt::WA_DeleteOnClose);
749+
// When the user closes it, reset our pointer so we can open a new one later
750+
connect(_shipEditorDialog, &QObject::destroyed, this, [this]() {
751+
_shipEditorDialog = nullptr;
752+
});
753+
_shipEditorDialog->show();
754+
} else {
755+
_shipEditorDialog->raise();
756+
_shipEditorDialog->activateWindow();
757+
}
749758

750759
}
751760
void FredView::on_actionCampaign_triggered(bool) {

qtfred/src/ui/FredView.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ namespace fred {
1919
class Editor;
2020
class RenderWidget;
2121

22+
namespace dialogs {
23+
class ShipEditorDialog;
24+
}
25+
2226
namespace Ui {
2327
class FredView;
2428
}
@@ -206,6 +210,8 @@ class FredView: public QMainWindow, public IDialogProvider {
206210
Editor* fred = nullptr;
207211
EditorViewport* _viewport = nullptr;
208212

213+
fso::fred::dialogs::ShipEditorDialog* _shipEditorDialog = nullptr;
214+
209215
bool _inKeyPressHandler = false;
210216
bool _inKeyReleaseHandler = false;
211217

0 commit comments

Comments
 (0)