Skip to content

Commit 77ec6e3

Browse files
committed
Fix UI crash when attempting to create profile with no templates present
1 parent 05661f4 commit 77ec6e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CustomizePlus/UI/Windows/Controls/TemplateCombo.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ protected bool Draw(Template? currentTemplate, string? label, float width)
7474
{
7575
_currentTemplate = currentTemplate;
7676
UpdateCurrentSelection();
77+
7778
InnerWidth = 400 * ImGuiHelpers.GlobalScale;
78-
CurrentSelectionIdx = Math.Max(Items.IndexOf(p => currentTemplate == p.Item1), 0);
79-
CurrentSelection = Items[CurrentSelectionIdx];
79+
80+
if(Items.Count > 0)
81+
{
82+
CurrentSelectionIdx = Math.Max(Items.IndexOf(p => currentTemplate == p.Item1), 0);
83+
CurrentSelection = Items[CurrentSelectionIdx];
84+
}
85+
8086
var name = label ?? "Select Template Here...";
8187
var ret = Draw("##template", name, string.Empty, width, ImGui.GetTextLineHeightWithSpacing())
8288
&& CurrentSelection != null;

0 commit comments

Comments
 (0)