--- server/display-channel.c | 3 --- server/red-parse-qxl.c | 12 ++++++++---- server/red-parse-qxl.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/display-channel.c b/server/display-channel.c index 91ef72215..e68ed10f8 100644 --- a/server/display-channel.c +++ b/server/display-channel.c @@ -286,7 +286,6 @@ static void stop_streams(DisplayChannel *display) void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id) { RedSurface *surface = &display->priv->surfaces[surface_id]; - QXLInstance *qxl = display->priv->qxl; DisplayChannelClient *dcc; if (--surface->refs != 0) { @@ -301,12 +300,10 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id) surface->context.canvas->ops->destroy(surface->context.canvas); if (surface->create_cmd != NULL) { - red_qxl_release_resource(qxl, surface->create_cmd->release_info_ext); red_surface_cmd_unref(surface->create_cmd); surface->create_cmd = NULL; } if (surface->destroy_cmd != NULL) { - red_qxl_release_resource(qxl, surface->destroy_cmd->release_info_ext); red_surface_cmd_unref(surface->destroy_cmd); surface->destroy_cmd = NULL; } diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c index 736e66d97..95c4c643f 100644 --- a/server/red-parse-qxl.c +++ b/server/red-parse-qxl.c @@ -1411,8 +1411,9 @@ bool red_validate_surface(uint32_t width, uint32_t height, return true; } -static bool red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, +static bool red_get_surface_cmd(QXLInstance *qxl_instance, RedMemSlotInfo *slots, int group_id, RedSurfaceCmd *red, QXLPHYSICAL addr) + { QXLSurfaceCmd *qxl; uint64_t size; @@ -1421,6 +1422,7 @@ static bool red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, if (qxl == NULL) { return false; } + red->qxl = qxl_instance; red->release_info_ext.info = &qxl->release_info; red->release_info_ext.group_id = group_id; @@ -1453,7 +1455,9 @@ static bool red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, static void red_put_surface_cmd(RedSurfaceCmd *red) { - /* nothing yet */ + if (red->qxl) { + red_qxl_release_resource(red->qxl, red->release_info_ext); + } } RedSurfaceCmd *red_surface_cmd_new(QXLInstance *qxl_instance, RedMemSlotInfo *slots, @@ -1465,8 +1469,8 @@ RedSurfaceCmd *red_surface_cmd_new(QXLInstance *qxl_instance, RedMemSlotInfo *sl cmd->refs = 1; - if (!red_get_surface_cmd(slots, group_id, cmd, addr)) { - g_free(cmd); + if (!red_get_surface_cmd(qxl_instance, slots, group_id, cmd, addr)) { + red_surface_cmd_unref(cmd); return NULL; } diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h index 37e4ffb21..43ace663b 100644 --- a/server/red-parse-qxl.h +++ b/server/red-parse-qxl.h @@ -85,6 +85,7 @@ typedef struct RedSurfaceCreate { } RedSurfaceCreate; typedef struct RedSurfaceCmd { + QXLInstance *qxl; QXLReleaseInfoExt release_info_ext; int refs; uint32_t surface_id; -- 2.19.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel