Commit fb0f7da17e60edd3ea752ea176707a26627fe205

Thomas de Grivel 2015-07-23T18:41:57

Fix get-resource.

diff --git a/core/resource-container.lisp b/core/resource-container.lisp
index 57d6727..0a84588 100644
--- a/core/resource-container.lisp
+++ b/core/resource-container.lisp
@@ -26,14 +26,19 @@
 (defun clear-resource-registry (rr)
   (clrhash rr))
 
-(defun get-resource (type id &optional (container (resource-registry
-                                                   *parent-resource*)))
-  (gethash (cons type id) container))
+(defun get-resource (type id &optional (container *parent-resource*))
+  (gethash (cons type id)
+           (typecase container
+             (resource-container (resource-registry container))
+             (t container))))
 
-(defsetf get-resource (type id &optional (container '(resource-registry
-                                                      *parent-resource*)))
+(defsetf get-resource (type id &optional (container '*parent-resource*))
     (value)
-  `(setf (gethash (cons ,type ,id) ,container) ,value))
+  `(setf (gethash (cons ,type ,id)
+                  (typecase ,container
+                    (resource-container (resource-registry ,container))
+                    (t ,container)))
+         ,value))
 
 (defun add-resource (parent child)
   (setf (get-resource (resource-type child)