--- old-clx/display.lisp	2008-08-21 23:29:29.000000000 -0400
+++ new-clx/display.lisp	2008-08-21 23:29:29.000000000 -0400
@@ -155,11 +155,12 @@
 
 (defmacro allocate-resource-id (display object type)
   ;; Allocate a resource-id for OBJECT in DISPLAY
-  (if (member (eval type) +clx-cached-types+)
-      `(let ((id (funcall (display-xid ,display) ,display)))
-	 (save-id ,display id ,object)
-	 id)
-    `(funcall (display-xid ,display) ,display)))
+  `(with-display (,display)
+     ,(if (member (eval type) +clx-cached-types+)
+          `(let ((id (funcall (display-xid ,display) ,display)))
+             (save-id ,display id ,object)
+             id)
+          `(funcall (display-xid ,display) ,display))))
 
 (defmacro deallocate-resource-id (display id type)
   ;; Deallocate a resource-id for OBJECT in DISPLAY
@@ -167,7 +168,8 @@
     `(deallocate-resource-id-internal ,display ,id)))
 
 (defun deallocate-resource-id-internal (display id)
-  (remhash id (display-resource-id-map display)))
+  (with-display (display)
+    (remhash id (display-resource-id-map display))))
 
 (defun lookup-resource-id (display id)
   ;; Find the object associated with resource ID

