CA-236844: XenCenter throws "Assertion failed" error when toggling be… (#1419)

* CA-236844: XenCenter throws "Assertion failed" error when toggling between the RDP and VNC consoles

Couldn't reproduce it, but it looks like the assertion is hit because the console view still holds a subscription to an event from an old vnc stream (maybe not garbage collected yet).
Added code to deregister event handlers when the vcnStream is disconnected and also replaced the the assertion with an if statement, ignoring the case that might have caused the assertion failure.

* CA-236844: XenCenter throws "Assertion failed" error when toggling between the RDP and VNC consoles

Added a Debug assert and a null check.

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2017-02-01 12:55:00 +00:00 committed by Stephen Turner
parent dbd60f1365
commit ce8cdce0a4

View File

@ -248,8 +248,11 @@ namespace XenAdmin.ConsoleView
private void OnError(object sender, Exception e)
{
Program.AssertOffEventThread();
System.Diagnostics.Trace.Assert(sender == this.vncStream);
System.Diagnostics.Debug.Assert(sender == vncStream); // Please see to CA-236844 if this assertion fails
if (sender != vncStream)
return;
this.connected = false;
if (ErrorOccurred != null)
ErrorOccurred(this, e);
@ -262,6 +265,11 @@ namespace XenAdmin.ConsoleView
{
connected = false;
terminated = true;
if (vncStream != null)
{
vncStream.ErrorOccurred -= OnError;
vncStream.ConnectionSuccess -= vncStream_ConnectionSuccess;
}
VNCStream s = vncStream;
vncStream = null;
if (s != null)