summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-01-22 14:01:56 +0100
committerDave Airlie <airlied@redhat.com>2016-02-10 12:39:48 +1000
commitdcc83cca07aee215047775fbb9aadff141a6624a (patch)
tree089fbc63f67969b711cce2545605cd9336991844
parent3ff41ae3848c3c454f1b2c9fec6ef62509ce979a (diff)
renderer: unref resource when destroying hashtable element
Resources are reference-counted, if another object holds a reference to a resource, it should not free it. Change the resource hashtable destroy callback to unref. Currently, this doesn't happen, since the resource hashtable is kept until the renderer is reset. However, in the next commit, the destroy callback will be used if a resource is replaced in the hashtable, and we want to keep the original resource. Furthermore, even if replace shouldn't happen, it avoids confusion and future errors if use only reference-counting mechanism. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--src/vrend_renderer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 4f189c5..826feb7 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -4236,7 +4236,9 @@ void vrend_renderer_resource_destroy(struct vrend_resource *res, bool remove)
static void vrend_destroy_resource_object(void *obj_ptr)
{
struct vrend_resource *res = obj_ptr;
- vrend_renderer_resource_destroy(res, false);
+
+ if (pipe_reference(&res->base.reference, NULL))
+ vrend_renderer_resource_destroy(res, false);
}
void vrend_renderer_resource_unref(uint32_t res_handle)