From 5adc4de71f8c70ecef3e2a47007ab1bfbf27069e Mon Sep 17 00:00:00 2001 From: MgAl2O4 <51430403+MgAl2O4@users.noreply.github.com> Date: Fri, 24 Sep 2021 14:26:31 -0400 Subject: [PATCH] fixed asserts on closing imgui file dialog --- .../ImGuiFileDialog/FileDialog.UI.cs | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index 9d30a5312..121fdbb6d 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -50,37 +50,40 @@ namespace Dalamud.Interface.ImGuiFileDialog windowVisible = ImGui.Begin(name, ref this.visible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoNav); } + bool wasClosed = false; if (windowVisible) { if (!this.visible) { // window closed this.isOk = false; - return true; + wasClosed = true; } - - if (this.selectedFilter.Empty() && (this.filters.Count > 0)) + else { - this.selectedFilter = this.filters[0]; - } - - if (this.files.Count == 0) - { - if (!string.IsNullOrEmpty(this.defaultFileName)) + if (this.selectedFilter.Empty() && (this.filters.Count > 0)) { - this.SetDefaultFileName(); - this.SetSelectedFilterWithExt(this.defaultExtension); - } - else if (this.IsDirectoryMode()) - { - this.SetDefaultFileName(); + this.selectedFilter = this.filters[0]; } - this.ScanDir(this.currentPath); - } + if (this.files.Count == 0) + { + if (!string.IsNullOrEmpty(this.defaultFileName)) + { + this.SetDefaultFileName(); + this.SetSelectedFilterWithExt(this.defaultExtension); + } + else if (this.IsDirectoryMode()) + { + this.SetDefaultFileName(); + } - this.DrawHeader(); - this.DrawContent(); - res = this.DrawFooter(); + this.ScanDir(this.currentPath); + } + + this.DrawHeader(); + this.DrawContent(); + res = this.DrawFooter(); + } if (this.isModal && !this.okResultToConfirm) { @@ -93,7 +96,7 @@ namespace Dalamud.Interface.ImGuiFileDialog ImGui.End(); } - return this.ConfirmOrOpenOverWriteFileDialogIfNeeded(res); + return wasClosed || this.ConfirmOrOpenOverWriteFileDialogIfNeeded(res); } private static void AddToIconMap(string[] extensions, char icon, Vector4 color)