[Openmcl-devel] CCL upgrading issues

Keith L. Downing keithd at idi.ntnu.no
Mon Sep 20 03:34:29 PDT 2010


   I wish I could give more details on this bug, but I'm having a hard  
time isolating it.  Maybe the following explanation will trigger an  
"oh, that's easy" reaction
in one of you.

   I've been trying to upgrade from CCL 1.1 to 1.4, but I run into a  
problem in 1.4.  It could easily be something that happens in 1.1 as  
well (and I just don't get the nice
error messages in 1.1), but I seem to be able to do longer (at least)  
runs in 1.1 before any melt-downs occur.

   I'm drawing a lot of graphics windows, some with simple x-y plots  
and some with more detailed cell grids (with each cell being a  
different color).  So there's a lot of
drawing going on.  Although I first thought that the crashes were due  
to the cell-grid plots, it now just seems like I get the crash after  
"a bit" of plotting.  Sometimes the
crash comes after 5 or 6 windows.  Sometimes I get 15 or 20 up there  
before everything hangs, but it does seem like the probability of a  
crash increases with the
number of cell grids that I draw.

   The error message is normally the same: a nil macptr in a call to  

Here's a live specimen:

   > Error: value NIL is not of the expected type MACPTR.
 > While executing: (:INTERNAL KD-PACK::|-[CocoaGraphicFrameView  
drawRect:]|), in process Initial(0).

   KD-PACK is my own package in which everything resides.

   I use rectangles (via make-ns-rect) both to draw windows and to  
draw little rectangles (i.e. cells) in my cell grids.  So, if I'm  
doing something sketchy, then I'm certainly rolling the dice
more when I draw a cell grid, since each may involve 100 or more  

   So I'm wondering if there have been any changes from 1.1 to 1.4  
that would affect my ability to draw windows or rectangles?  Maybe 1.1  
was more forgiving of certain
errors?  I certainly had more compiler issues with 1.4 .

Here are my declarations for a window (I call it a "graphic-frame")  
and a view ("cocoa-graphic-frame-view")

(defclass graphic-frame ( #+(or CLIM WINDOWS MSWINDOWS) bitmap-window # 
+DIGITOOL ccl:window #+CLOZURE ns:ns-window)
    ((graphic-viewer :initarg :graphic-viewer :accessor graphic-viewer))
  #+CLOZURE (:metaclass ns:+ns-window)

(defclass cocoa-graphic-frame-view (ns:ns-view)
   (:metaclass ns:+ns-object))

I have only written one drawRect routine.  This just insures that all  
the information saved in my window object (graphic-viewer) gets  
redrawn to the main
window whenever the window is resized, moved, etc....or at least I  
think so.  A graphic-viewer is my own class for housing the details of  
a window, including the
actual graphic-frame.

(objc:defmethod (#/drawRect: :void) ((self cocoa-graphic-frame-view)  
(rect :<NSR>ect))
   (draw-all (graphic-viewer (#/window self))))

   Below is the code for drawing rectangles (in the cell grids).

(defun kd-draw-rectangle* (stream x y width height
                             &key (ink *kd-black-color*) (thickness 1)
                              (line-dashes *kd-solid-line-type*)
                              (filled nil) (fill-color *kd-black- 
color* fill-supplied?))
#+CLOZURE (declare (ignore stream))

   (if (and filled (not fill-supplied?))
       (setf fill-color ink))

     (let ((rect (ns:make-ns-rect x (- y height) width height))
	  (path (create-bezier-path)))
        (set-cocoa-line-specs path :width thickness :line-color  
ink :line-type line-dashes :fill-color fill-color)
       (#/appendBezierPathWithRect: path rect)
       (#/stroke path)
        (if (and filled fill-color) (#/fill path)))

;;  Below is the code for creating a window.  I have experimented with  
with-autorelease-pool, but it doesn't seem to make much difference.  I  
was recently told that
;; it was redundant, since there is already an autorelease pool for  
the main GUI thread. The same goes for the
;; 2 versions of setContentView, one with and one without the  
autorelease: neither seems to make a big difference.  Graphic-viewer  
is my own CCL window
;; object.  It's "viewer" slot

(defmethod create-viewer ((gv graphic-viewer))
   (let* ((rect (ns:make-ns-rect 0 0 (window-width gv) (window-height  
	 (w (make-instance 'graphic-frame :with-content-rect rect :graphic- 
viewer gv
	            :style-mask (logior #$NSTitledWindowMask
		     :backing #$NSBackingStoreBuffered :defer t))
	 (pos (init-position gv)))
     (with-ns-string (cocoa-string (title gv))
         (#/setTitle: w cocoa-string))
     ;; (#/setContentView: w (#/autorelease (make-instance 'cocoa- 
     (#/setContentView: w (make-instance 'cocoa-graphic-frame-view))
     (#/center w)
     (#/orderFront: w nil)
     (setf (viewer gv) (#/contentView w))
     (kd-window-move (viewer gv) (first pos) (second pos))
     (update-drawing-dims gv)))

Thanks for the help....

     Keith Downing
    Trondheim, Norway

More information about the Openmcl-devel mailing list