XFT: Make destroying of an `XftDraw*` more robust jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 09 Jan 2017 21:14:42 +0000
branchjv
changeset 7772 a59648e60593
parent 7771 3e74422a72dd
child 7773 8c70a4ba1cf2
XFT: Make destroying of an `XftDraw*` more robust ...expecially guard against double call to `XftDrawDestroy()` with the same `XftDraw*`.
XGraphicsContext.st
XftFontDescription.st
--- 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);