mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Guard against potential usage of DrawablePool without being added to hierarchy
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user