Merge pull request #106 from Caraxi/master

Avoid crashing when clicking Choose with no item selected
This commit is contained in:
goaaats 2020-05-03 16:34:54 +02:00 committed by GitHub
commit 009a4901f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -186,14 +186,22 @@ namespace Dalamud.Interface
ImGui.EndChild(); ImGui.EndChild();
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) { // Darken choose button if it shouldn't be clickable
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]); ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 ? 0.25f : 1);
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
try {
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);
if (this.closeOnChoose) { if (this.closeOnChoose) {
this.selectedItemTex?.Dispose(); this.selectedItemTex?.Dispose();
isOpen = false; isOpen = false;
} }
} catch (Exception ex) {
Log.Error($"Exception in Choose: {ex.Message}");
} }
}
ImGui.PopStyleVar();
if (!this.closeOnChoose) { if (!this.closeOnChoose) {
ImGui.SameLine(); ImGui.SameLine();