Skip to content

Commit e7e3a25

Browse files
committed
Fix non-empty project folder confirmation dialog
1 parent 9aed9ec commit e7e3a25

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

editor/project_manager/project_dialog.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,14 @@ void ProjectDialog::ok_pressed() {
488488
// Before we create a project, check that the target folder is empty.
489489
// If not, we need to ask the user if they're sure they want to do this.
490490
if (!is_folder_empty) {
491-
ConfirmationDialog *cd = memnew(ConfirmationDialog);
492-
cd->set_title(TTR("Warning: This folder is not empty"));
493-
cd->set_text(TTR("You are about to create a Godot project in a non-empty folder.\nThe entire contents of this folder will be imported as project resources!\n\nAre you sure you wish to continue?"));
494-
cd->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_nonempty_confirmation_ok_pressed));
495-
get_parent()->add_child(cd);
496-
cd->popup_centered();
491+
if (!nonempty_confirmation) {
492+
nonempty_confirmation = memnew(ConfirmationDialog);
493+
nonempty_confirmation->set_title(TTR("Warning: This folder is not empty"));
494+
nonempty_confirmation->set_text(TTR("You are about to create a Godot project in a non-empty folder.\nThe entire contents of this folder will be imported as project resources!\n\nAre you sure you wish to continue?"));
495+
nonempty_confirmation->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_nonempty_confirmation_ok_pressed));
496+
add_child(nonempty_confirmation);
497+
}
498+
nonempty_confirmation->popup_centered();
497499
return;
498500
}
499501

editor/project_manager/project_dialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ProjectDialog : public ConfirmationDialog {
6565

6666
Mode mode = MODE_NEW;
6767
bool is_folder_empty = true;
68+
ConfirmationDialog *nonempty_confirmation = nullptr;
6869

6970
CheckButton *create_dir = nullptr;
7071
Button *project_browse = nullptr;

0 commit comments

Comments
 (0)