fix: use ImRaii for PI DrawPluginCategories

Prevents mismatched BeginTable/EndTable
This commit is contained in:
goat 2023-06-21 19:13:33 +02:00
parent a954e83976
commit c68793b589
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -1110,11 +1110,14 @@ internal class PluginInstallerWindow : Window, IDisposable
var useContentWidth = ImGui.GetContentRegionAvail().X; var useContentWidth = ImGui.GetContentRegionAvail().X;
if (ImGui.BeginChild("InstallerCategories", new Vector2(useContentWidth, useContentHeight * ImGuiHelpers.GlobalScale))) using (ImRaii.Child("InstallerCategories", new Vector2(useContentWidth, useContentHeight * ImGuiHelpers.GlobalScale)))
{
ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0));
if (ImGui.BeginTable("##InstallerCategoriesCont", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV))
{ {
using var style = ImRaii.PushStyle(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0));
using var table = ImRaii.Table(
"##InstallerCategoriesCont",
2,
ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV);
try try
{ {
ImGui.TableSetupColumn("##InstallerCategoriesSelector", ImGuiTableColumnFlags.WidthFixed, useMenuWidth * ImGuiHelpers.GlobalScale); ImGui.TableSetupColumn("##InstallerCategoriesSelector", ImGuiTableColumnFlags.WidthFixed, useMenuWidth * ImGuiHelpers.GlobalScale);
@ -1125,7 +1128,7 @@ internal class PluginInstallerWindow : Window, IDisposable
this.DrawPluginCategorySelectors(); this.DrawPluginCategorySelectors();
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if (ImGui.BeginChild("ScrollingPlugins", new Vector2(-1, 0), false, ImGuiWindowFlags.NoBackground)) using (ImRaii.Child("ScrollingPlugins", new Vector2(-1, 0), false, ImGuiWindowFlags.NoBackground))
{ {
try try
{ {
@ -1136,19 +1139,11 @@ internal class PluginInstallerWindow : Window, IDisposable
Log.Error(ex, "Could not draw category content"); Log.Error(ex, "Could not draw category content");
} }
} }
ImGui.EndChild();
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Could not draw plugin categories"); Log.Error(ex, "Could not draw plugin categories");
} }
ImGui.EndTable();
}
ImGui.PopStyleVar();
ImGui.EndChild();
} }
} }