Skip to content

Commit 2cc80ce

Browse files
authored
GraphicsResourceStrategy.Dispose() (#2334)
similar to #1559 prevents InvalidOperationException when setting WeakReference.Target to null and the target is allready sceduled for collection. fixes the issue with GUM editor vchelaru/Gum#749
1 parent 7182fc1 commit 2cc80ce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Xna.Framework.Graphics/Graphics/GraphicsResourceStrategy.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public GraphicsDevice GraphicsDevice
3434
GraphicsResource IGraphicsResourceStrategy.GraphicsResource
3535
{
3636
get { return _graphicsResourceRef.Target as GraphicsResource;}
37-
set { _graphicsResourceRef.Target = value; }
37+
set
38+
{
39+
if (_graphicsResourceRef.Target != null || value != null)
40+
_graphicsResourceRef.Target = value;
41+
}
3842
}
3943

4044
internal GraphicsResourceStrategy()

0 commit comments

Comments
 (0)