[gnome-boxes] Do main channel handlers clean-up
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Do main channel handlers clean-up
- Date: Fri, 7 Sep 2012 16:27:51 +0000 (UTC)
commit fbfdb721f65889e57b4c3d6be2eba6b36c0a5893
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Sep 7 12:42:02 2012 +0200
Do main channel handlers clean-up
Spice-gtk has a peculiar (and annoying) channel object memory
management model... Channels are actually removed from the session
when the refcount reaches 0. If not, bad interactions with new
channels happen (if the session is recycled on reconnect or migration).
I wish spice-gtk would be fixed to be simpler to use, but Boxes can
also learn to clean up old handlers.
https://bugzilla.gnome.org/show_bug.cgi?id=683561
src/spice-display.vala | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 7294fac..df428b0 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -50,6 +50,26 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
App.app.notify["ui-state"].connect (ui_state_changed);
}
+ Spice.MainChannel? main_channel;
+ ulong main_event_id;
+ ulong main_mouse_mode_id;
+
+ private void main_cleanup () {
+ if (main_channel == null)
+ return;
+
+ var o = main_channel as Object;
+ o.disconnect (main_event_id);
+ main_event_id = 0;
+ o.disconnect (main_mouse_mode_id);
+ main_mouse_mode_id = 0;
+ main_channel = null;
+ }
+
+ ~SpiceDisplay () {
+ main_cleanup ();
+ }
+
public SpiceDisplay (DisplayConfig config, string host, int port) {
this.config = config;
@@ -100,18 +120,20 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
}
public override void connect_it () {
+ main_cleanup ();
+
// FIXME: vala does't want to put this in ctor..
if (channel_new_id == 0)
channel_new_id = session.channel_new.connect ((channel) => {
var id = channel.channel_id;
if (channel is Spice.MainChannel) {
- var main = channel as Spice.MainChannel;
- main.channel_event.connect (main_event);
- main.notify["mouse-mode"].connect(() => {
- can_grab_mouse = main.mouse_mode != 2;
+ main_channel = channel as Spice.MainChannel;
+ main_event_id = main_channel.channel_event.connect (main_event);
+ main_mouse_mode_id = main_channel.notify["mouse-mode"].connect(() => {
+ can_grab_mouse = main_channel.mouse_mode != 2;
});
- can_grab_mouse = main.mouse_mode != 2;
+ can_grab_mouse = main_channel.mouse_mode != 2;
}
if (channel is Spice.DisplayChannel) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]