From 283286e0cd3dcc54157e9a84c9fd78fe136836bc Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Thu, 8 May 2014 23:57:01 +0200 Subject: [PATCH] wrlib: Implemented functions to allow clean-up of Contexts The function 'RDestroyContext' have been defined in the API for a long time but did not have an implementation, this patch fixes it. --- wrlib/context.c | 15 +++++++++++++++ wrlib/libwraster.map | 1 + 2 files changed, 16 insertions(+) diff --git a/wrlib/context.c b/wrlib/context.c index b6794d08..74790092 100644 --- a/wrlib/context.c +++ b/wrlib/context.c @@ -688,6 +688,21 @@ RContext *RCreateContext(Display * dpy, int screen_number, const RContextAttribu return context; } +void RDestroyContext(RContext *context) +{ + if (context) { + if (context->copy_gc) + XFreeGC(context->dpy, context->copy_gc); + if (context->attribs) { + if ((context->attribs->flags & RC_VisualID) && + !(context->attribs->flags & RC_DefaultVisual)) + XDestroyWindow(context->dpy, context->drawable); + free(context->attribs); + } + free(context); + } +} + static Bool bestContext(Display * dpy, int screen_number, RContext * context) { XVisualInfo *vinfo = NULL, rvinfo; diff --git a/wrlib/libwraster.map b/wrlib/libwraster.map index 6e165ef0..422af756 100644 --- a/wrlib/libwraster.map +++ b/wrlib/libwraster.map @@ -33,6 +33,7 @@ LIBWRASTER3 RConvertImageMask; RCopyArea; RCreateContext; + RDestroyContext; RCreateImage; RCreateImageFromDrawable; RCreateImageFromXImage;