[Spice-devel] [PATCH spice-gtk 13/14] display: unshare the palette cache

Marc-André Lureau marcandre.lureau at gmail.com
Tue Sep 10 07:44:12 PDT 2013


As pointed out by Yonit on the ML:
> (1) the palette cache shouldn't be shared among the display channels. I.e.,
> there should be one instance per channel, and not one instance in
> spice-session.
---
 gtk/channel-display.c    | 4 +++-
 gtk/spice-session-priv.h | 1 -
 gtk/spice-session.c      | 6 ------
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 0af3859..794f4eb 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -144,6 +144,7 @@ static void spice_display_channel_finalize(GObject *object)
     clear_surfaces(SPICE_CHANNEL(object), FALSE);
     g_hash_table_unref(c->surfaces);
     clear_streams(SPICE_CHANNEL(object));
+    g_clear_pointer(&c->palettes, cache_unref);
 
     if (G_OBJECT_CLASS(spice_display_channel_parent_class)->finalize)
         G_OBJECT_CLASS(spice_display_channel_parent_class)->finalize(object);
@@ -155,7 +156,8 @@ static void spice_display_channel_constructed(GObject *object)
     SpiceSession *s = spice_channel_get_session(SPICE_CHANNEL(object));
 
     g_return_if_fail(s != NULL);
-    spice_session_get_caches(s, &c->images, &c->palettes, &c->glz_window);
+    spice_session_get_caches(s, &c->images, &c->glz_window);
+    c->palettes = cache_new(g_free);
 
     g_return_if_fail(c->glz_window != NULL);
     g_return_if_fail(c->images != NULL);
diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index e175281..55fee47 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -147,7 +147,6 @@ void spice_session_set_caches_hints(SpiceSession *session,
                                     uint32_t display_channels_count);
 void spice_session_get_caches(SpiceSession *session,
                               display_cache **images,
-                              display_cache **palettes,
                               SpiceGlzDecoderWindow **glz_window);
 void spice_session_palettes_clear(SpiceSession *session);
 void spice_session_images_clear(SpiceSession *session);
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index c050266..79a13de 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -177,7 +177,6 @@ static void spice_session_init(SpiceSession *session)
 
     ring_init(&s->channels);
     s->images = cache_new((GDestroyNotify)pixman_image_unref);
-    s->palettes = cache_new(g_free);
     s->glz_window = glz_decoder_window_new();
     update_proxy(session, NULL);
 }
@@ -239,7 +238,6 @@ spice_session_finalize(GObject *gobject)
     g_strfreev(s->secure_channels);
 
     g_clear_pointer(&s->images, cache_unref);
-    g_clear_pointer(&s->palettes, cache_unref);
     glz_decoder_window_destroy(s->glz_window);
 
     g_clear_pointer(&s->pubkey, g_byte_array_unref);
@@ -1308,7 +1306,6 @@ static void cache_clear_all(SpiceSession *self)
     SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(self);
 
     cache_clear(s->images);
-    cache_clear(s->palettes);
     glz_decoder_window_clear(s->glz_window);
 }
 
@@ -2087,7 +2084,6 @@ const gchar* spice_session_get_ca_file(SpiceSession *session)
 G_GNUC_INTERNAL
 void spice_session_get_caches(SpiceSession *session,
                               display_cache **images,
-                              display_cache **palettes,
                               SpiceGlzDecoderWindow **glz_window)
 {
     SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
@@ -2096,8 +2092,6 @@ void spice_session_get_caches(SpiceSession *session,
 
     if (images)
         *images = s->images;
-    if (palettes)
-        *palettes = s->palettes;
     if (glz_window)
         *glz_window = s->glz_window;
 }
-- 
1.8.3.1



More information about the Spice-devel mailing list