Index: /trunk/source/objc-bridge/objc-package.lisp
===================================================================
--- /trunk/source/objc-bridge/objc-package.lisp	(revision 14202)
+++ /trunk/source/objc-bridge/objc-package.lisp	(revision 14203)
@@ -45,4 +45,5 @@
            "OBJC-MESSAGE-SEND-SUPER" "OBJC-MESSAGE-SEND-SUPER-STRET"
            "LOAD-FRAMEWORK" "*OBJC-DESCRIPTION-MAX-LENGTH*"
+           "REMOVE-LISP-SLOTS"
            ))
 
Index: /trunk/source/objc-bridge/objc-runtime.lisp
===================================================================
--- /trunk/source/objc-bridge/objc-runtime.lisp	(revision 14202)
+++ /trunk/source/objc-bridge/objc-runtime.lisp	(revision 14203)
@@ -2470,4 +2470,5 @@
     (#___objc_exec_class m)))
 
+
 #+(or apple-objc-2.0 cocotron-objc)
 (defun %add-objc-class (class)
@@ -2753,4 +2754,10 @@
 
 
+
+
+
+                                  
+                   
+                                
 
 
@@ -3083,5 +3090,5 @@
   #+gnu-objc (#_method_get_number_of_arguments m))
 
-#+(or apple-objc cocotron-objc)
+#+(and bad-idea (or apple-objc cocotron-objc))
 (progn
 (defloadvar *original-deallocate-hook* nil)
Index: /trunk/source/objc-bridge/objc-support.lisp
===================================================================
--- /trunk/source/objc-bridge/objc-support.lisp	(revision 14202)
+++ /trunk/source/objc-bridge/objc-support.lisp	(revision 14203)
@@ -168,5 +168,25 @@
                      (nsobject-description (ns-exception c))))))
 
-
+(defun ensure-dealloc-method-for-class (class)
+  (let* ((direct-slots (class-direct-slots class))
+         (effective-slots (class-slots class)))
+    (when (and (dolist (d direct-slots)
+                 (when (and (typep d 'standard-direct-slot-definition)
+                            (eq :instance (slot-definition-allocation d)))
+                   (return t)))
+               (dolist (e effective-slots t)
+                 (when (and (typep e 'standard-effective-slot-definition)
+                            (eq :instance (slot-definition-allocation e))
+                            (not (find (slot-definition-name e)
+                                       direct-slots
+                                         :key #'slot-definition-name
+                                         :test #'eq)))
+                   (return))))
+      (eval `(objc:defmethod (#/dealloc :void) ((self ,(class-name class)))
+              (objc:remove-lisp-slots self)
+              (call-next-method))))))
+
+(eval-when (:compile-toplevel :execute)
+  (declaim (ftype (function (&rest t) t) objc-callback-error-return)))
 
 (defclass ns-lisp-exception (ns::ns-exception)
