XFT: Make destroying of an `XftDraw*` more robust
...expecially guard against double call to `XftDrawDestroy()` with
the same `XftDraw*`.
--- a/XGraphicsContext.st Fri Jan 06 23:53:36 2017 +0000
+++ b/XGraphicsContext.st Mon Jan 09 21:14:42 2017 +0000
@@ -30,7 +30,11 @@
destroy
xftDrawId notNil ifTrue:[
- XftFontDescription xftDrawDestroy: xftDrawId
+ | id |
+
+ id := xftDrawId.
+ xftDrawId := nil.
+ XftFontDescription xftDrawDestroy: id.
].
super destroy.
--- a/XftFontDescription.st Fri Jan 06 23:53:36 2017 +0000
+++ b/XftFontDescription.st Mon Jan 09 21:14:42 2017 +0000
@@ -307,8 +307,9 @@
xftDrawDestroy: xftDrawId
%{
#ifdef XFT
- if (__isExternalAddressLike(xftDrawId)) {
- XftDraw *xftDraw = XFT_DRAW(xftDrawId);
+ XftDraw *xftDraw;
+ if (__isExternalAddressLike(xftDrawId) && (xftDraw = XFT_DRAW(xftDrawId)) != NULL) {
+ __externalAddressVal(xftDrawId) = NULL;
XftDrawDestroy(xftDraw);
}
RETURN (self);