C#: Throw ObjectDisposedException from disposed wrapper classes
This commit is contained in:
parent
325efb60b7
commit
efd5d4bcf9
@ -50,6 +50,9 @@ namespace Godot.Collections
|
||||
|
||||
internal IntPtr GetPtr()
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
return safeHandle.DangerousGetHandle();
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,9 @@ namespace Godot.Collections
|
||||
|
||||
internal IntPtr GetPtr()
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException(GetType().FullName);
|
||||
|
||||
return safeHandle.DangerousGetHandle();
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,13 @@ namespace Godot
|
||||
|
||||
internal static IntPtr GetPtr(NodePath instance)
|
||||
{
|
||||
return instance == null ? IntPtr.Zero : instance.ptr;
|
||||
if (instance == null)
|
||||
return IntPtr.Zero;
|
||||
|
||||
if (instance.disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
}
|
||||
|
||||
~NodePath()
|
||||
@ -49,7 +55,7 @@ namespace Godot
|
||||
get { return ptr; }
|
||||
}
|
||||
|
||||
public NodePath() : this(string.Empty) {}
|
||||
public NodePath() : this(string.Empty) { }
|
||||
|
||||
public NodePath(string path)
|
||||
{
|
||||
|
@ -30,7 +30,13 @@ namespace Godot
|
||||
|
||||
internal static IntPtr GetPtr(Object instance)
|
||||
{
|
||||
return instance == null ? IntPtr.Zero : instance.ptr;
|
||||
if (instance == null)
|
||||
return IntPtr.Zero;
|
||||
|
||||
if (instance.disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
}
|
||||
|
||||
~Object()
|
||||
|
@ -11,7 +11,13 @@ namespace Godot
|
||||
|
||||
internal static IntPtr GetPtr(RID instance)
|
||||
{
|
||||
return instance == null ? IntPtr.Zero : instance.ptr;
|
||||
if (instance == null)
|
||||
return IntPtr.Zero;
|
||||
|
||||
if (instance.disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
}
|
||||
|
||||
~RID()
|
||||
|
Loading…
Reference in New Issue
Block a user