From 8615d14f0909c688b095209a05a43685dfe0df3c Mon Sep 17 00:00:00 2001
From: DE YU <71481700+Delsin-Yu@users.noreply.github.com>
Date: Mon, 14 Oct 2024 20:08:02 +0800
Subject: [PATCH] Make IVirtualGridView implement IDisposable
---
GDViews.VirtualGridView/Core/IVirtualGridView.cs | 2 +-
GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs | 6 ++++++
GDViews.VirtualGridView/GDViews.VirtualGridView.csproj | 4 ++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/GDViews.VirtualGridView/Core/IVirtualGridView.cs b/GDViews.VirtualGridView/Core/IVirtualGridView.cs
index fd9a45d..f9242b2 100644
--- a/GDViews.VirtualGridView/Core/IVirtualGridView.cs
+++ b/GDViews.VirtualGridView/Core/IVirtualGridView.cs
@@ -10,7 +10,7 @@ namespace GodotViews.VirtualGrid;
/// to navigate through and customise the virtualized grid view.
///
/// The type for the data this controller focuses on.
-public interface IVirtualGridView
+public interface IVirtualGridView : IDisposable
{
///
/// Accessor for the currently active ElementPositioner,
diff --git a/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs b/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs
index c1da1b6..541134e 100644
--- a/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs
+++ b/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs
@@ -1183,4 +1183,10 @@ private class DataView
public NullableData Data;
public override string ToString() => $"Button: {AssignedButton?.Name ?? "Null"}, Data: {Data}";
}
+
+ ///
+ public void Dispose()
+ {
+ while (_buttonPool.TryPop(out var instance)) instance.QueueFree();
+ }
}
\ No newline at end of file
diff --git a/GDViews.VirtualGridView/GDViews.VirtualGridView.csproj b/GDViews.VirtualGridView/GDViews.VirtualGridView.csproj
index 6aab037..d55aa84 100644
--- a/GDViews.VirtualGridView/GDViews.VirtualGridView.csproj
+++ b/GDViews.VirtualGridView/GDViews.VirtualGridView.csproj
@@ -14,7 +14,7 @@
true
GDViews.VirtualGridView
- 0.0.2
+ 0.0.3
DE-YU
Based on DotNet, GDViews.VirtualGridView provides classes that are useful for creating highly customizable virtualized grid views.
https://www.nuget.org/packages/GDViews.VirtualGridView
@@ -22,7 +22,7 @@
https://github.com/Delsin-Yu/GDViews.VirtualGridView
git
Godot TabView
- Fix Mouse Wheel Scroll Event doubles, and fix scroll Bar is not accurately reflecting the virtual viewport position.
+ Make IVirtualGridView implement IDisposable, which allows for cleaning cached button instances that are out of the scene tree.
MIT
true