Commit 7fa00794 authored by Martin Finkel's avatar Martin Finkel

WinForms: Add native reference checks

parent f48c8d44
......@@ -77,7 +77,7 @@ namespace LibVLCSharp.WinForms
void Detach()
{
if (_mp == null)
if (_mp == null || _mp.NativeReference == IntPtr.Zero)
return;
_mp.Hwnd = IntPtr.Zero;
......@@ -85,7 +85,7 @@ namespace LibVLCSharp.WinForms
void Attach()
{
if (_mp == null)
if (_mp == null || _mp.NativeReference == IntPtr.Zero)
return;
_mp.Hwnd = Handle;
......@@ -103,14 +103,13 @@ namespace LibVLCSharp.WinForms
{
if (disposing)
{
if (MediaPlayer != null)
if (MediaPlayer != null && MediaPlayer.NativeReference != IntPtr.Zero)
{
MediaPlayer.Hwnd = IntPtr.Zero;
}
}
disposedValue = true;
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment