Guard against potential usage of DrawablePool without being added to hierarchy

This commit is contained in:
Dean Herbert
2024-01-15 20:38:55 +09:00
parent e6422d8de0
commit 50bdde8a46

View File

@@ -111,6 +111,9 @@ namespace osu.Framework.Graphics.Pooling
/// <returns>The drawable.</returns>
public T Get(Action<T> setupAction = null)
{
if (LoadState <= LoadState.Loading)
throw new InvalidOperationException($"A {nameof(DrawablePool<T>)} must be in a loaded state before retrieving pooled drawables.");
if (!pool.TryPop(out var drawable))
{
drawable = create();