Fix a regression when initial connection fails
Due to changes in commit 65ef66e4, when the initial connection fails,
virt-viewer just sat quietly and didn't indicate what was wrong. It also
did not exit as it did before. This is because we were using
virt_viewer_session_spice_channel_destroy() incorrectly. This function
was intended to be a callback that is called to clean up the VV session
when the SpiceSession tells us that a channel has been destroyed. It
does not actually destroy the channel, it only cleans up references to
that channel within virt-viewer. After calling this function, the
channel is not affected in any way. If the channel object was valid
before calling the function, it will be valid and unchanged after
calling the function as well.
The problem is that before commit 65ef66e4, this function
(_channel_destroy()) also had a side-effect of emitting a signal that
made us think that the SpiceSession was disconnected when it was not.
The application responded to this signal by exiting even though the
session was not properly disconnected and cleaned up.
We now no longer exit the application until the SpiceSession is properly
disconnected and cleaned up. So we need to make sure that this happens
when our initial connection fails. Therefore, when the main channel
receives an error channel-event, we should not call
virt_viewer_session_spice_channel_destroy(). This function should only
be called when a channel has actually been destroyed, and the channel is
not destroyed at this point. We should instead explicitly disconnect
the session, which will result in the channels being destroyed properly.
After the session destroys all of the channels, the 'channel-destroy' signal
will be emitted by SpiceSession, so the _channel_destroy() function will
eventually get called by the signal handler.
To make the proper use of the function more obvious, I also changed the
function name from _channel_destroy() to _channel_destroyed() and added
Signed-off-by: Jonathon Jongsma <firstname.lastname@example.org>
Acked-by: Christophe Fergeau <email@example.com>