Andy Chambers | 17 Aug 16:06 2007

restarting celtk

Hi,

When something goes wrong in a celtk program, how do you go about
cleaning all the tcl stuff up and starting again?

I tried doing

(tk-format-now "exit")

but that causes my slime to lose its connection with sbcl.  I'm not
sure whether this means that this action is causing sbcl itself to
crash but that is a possibility.  Is there some lisp function I can
call to reset the tcl interface.

Cheers,
Andy
Ken Tilton | 17 Aug 16:43 2007
Picon

Re: restarting celtk

Andy Chambers wrote:
> Hi,
> 
> When something goes wrong in a celtk program, how do you go about
> cleaning all the tcl stuff up and starting again?

I do not have a problem with Celtk as it stands (meaning "now that I 
have figured out the delicate choreography of messages arising when a TK 
window closes and setup Celtk internals to bow out gracefully"). So a 
specific error/situation/scenario needs to be delineated.

> 
> I tried doing
> 
> (tk-format-now "exit")

The end of the world as we know it. That, in my case, would bring down 
the IDE as well, since my app and IDE run in one Lisp process. In the 
case of Emacs you "just" lose the entire Lisp session.

> 
> but that causes my slime to lose its connection with sbcl.  I'm not
> sure whether this means that this action is causing sbcl itself to
> crash but that is a possibility.  Is there some lisp function I can
> call to reset the tcl interface.

Nothing special is needed. The window closes and the callback event 
handler eventually runs out of messages (or the tight loop polling for 
events exits -- forget the architecture because it has been years 
literally since I had to look at it.
(Continue reading)

Andy Chambers | 19 Aug 01:29 2007

Where do you keep the models?

Where should you keep the data in a celtk app.  I tried doing the following...

(defmodel app (window)
  ((my-model :initform nil :initarg :model :accessor my-model))
  (:default-initargs
      :kids (c? (the-kids
		 (mk-row (:packing (c?pack-self))
                   (mk-popup-menubutton
                    :id :view-selector
		    :initial-value (c? (first (^entry-values)))
		    :entry-values (c? '(codelists items item-groups forms events)))
                   (mk-text-widget
		    :id :display
		    :value (c? (if *odm*
				   (case (selection (fm^ :view-selector))
				     (codelists
				      (codelists *odm*))
				     (items
				      (items *odm*))
				     (t (xml *odm*)))))))))))

...but I couldn't work out how to access my-model from the text
widget's (c? ...).  What you see above is what I changed it to in
order to make it access the global *odm* variable which is elsewhere
set to be a normal cells instance.  Is there a way to keep it all in
the app?  I'd like to make it so that my-model is set by the result of
a file-open dialog.

Cheers,
Andy
(Continue reading)

Ken Tilton | 19 Aug 17:00 2007
Picon

Re: Where do you keep the models?

Andy Chambers wrote:
> Where should you keep the data in a celtk app.  I tried doing the following...
> 
> (defmodel app (window)
>   ((my-model :initform nil :initarg :model :accessor my-model))
>   (:default-initargs
>       :kids (c? (the-kids
> 		 (mk-row (:packing (c?pack-self))
>                    (mk-popup-menubutton
>                     :id :view-selector
> 		    :initial-value (c? (first (^entry-values)))
> 		    :entry-values (c? '(codelists items item-groups forms events)))
>                    (mk-text-widget
> 		    :id :display
> 		    :value (c? (if *odm*
> 				   (case (selection (fm^ :view-selector))
> 				     (codelists
> 				      (codelists *odm*))
> 				     (items
> 				      (items *odm*))
> 				     (t (xml *odm*)))))))))))
> 
> 
> ...but I couldn't work out how to access my-model from the text
> widget's (c? ...).

As long as you are using my Family class you have a name/typespace to 
work with, meaning various utilities prefixed "fm-" which navigate 
parent/kids to find things by name or type.

(Continue reading)

Frank Goenninger | 29 Aug 21:35 2007
Picon

Problem with defmd and dependency ...

Hi Kenny (and all on the list):

I have a simple defmd:

(defmd gnc-point ()
	(x (c-in 0))
	(y (c-in 0))
	(z (c-in 0))
	(foreign-ptr (c_? (let ((ptr (or (^foreign-ptr) (fgn-alloc 'glInt  
3 :gnc-point))))
							   (when ptr
								   (setf (eltgli ptr 0) (^x))
							     (setf (eltgli ptr 1) (^y))
							     (setf (eltgli ptr 2) (^z)))
								 ptr))))

This is a model for a point ( x | y | z ) and a foreign object  
pointer. The pointer shall be set to a an FFI memory pointer (via  
CFFI) when the instance is created. Also, the elements of the memory  
array (which is 3 glInt, this being three OpenGL Integers) shall be  
updated when any of the coordinates x y z is changed...

I get  x, y, and z updated but the foreign-ptr remains NIL ... What  
am I doing wrong ???

Thx!

Frank

(Continue reading)

Frank Goenninger | 29 Aug 21:50 2007
Picon

Re: Problem with defmd and dependency ...

Correct problem case:

I defined the foreign-ptr cell as lazy (as :until-asked) for a  
reason ... ->

0>  7612 calculating cell ~a appears in call stack: ~a dirty=0/ 
foreign-ptr/gnc-point0] dirty=0/foreign-ptr/gnc-point0]
(dirty=0/foreign-ptr/gnc-point0])

... landing in a (break) ...

Ok. So I am basically looking for an idiom on how to avoid the  
circularity. I sense there is a simple solution but ...

Oh my. It's been a long day ;-)

Frank

Am 29.08.2007 um 21:35 schrieb Frank Goenninger:

> * PGP Signed: 08/29/07 at 21:35:14
>
> Hi Kenny (and all on the list):
>
> I have a simple defmd:
>
> (defmd gnc-point ()
> 	(x (c-in 0))
> 	(y (c-in 0))
> 	(z (c-in 0))
(Continue reading)

Frank Goenninger | 29 Aug 22:16 2007
Picon

Re: SOLVED: Problem with defmd and dependency ...

Solved:

(defmd gnc-point ()
	(x (c-in 0))
	(y (c-in 0))
	(z (c-in 0))
	(foreign-ptr (c-in (fgn-alloc 'glInt 3 :gnc-point))))

(defobserver x ((self gnc-point))
	(with-integrity (:change self)
		(let ((ptr (^foreign-ptr)))
		  (if ptr
		      (setf (eltgli ptr 0) (^x))
		     (error "OBSERVER X OF ~S: FOREIGN-PTR is NIL (Foreign memory  
not available)" self)))))

(defobserver y ((self gnc-point))
	(with-integrity (:change self)
		(let ((ptr (^foreign-ptr)))
		  (if ptr
		      (setf (eltgli ptr 1) (^y))
		      (error "OBSERVER Y OF ~S: FOREIGN-PTR is NIL (Foreign memory  
not available)" self)))))

(defobserver z ((self gnc-point))
	(with-integrity (:change self)
		(let ((ptr (^foreign-ptr)))
		  (if ptr
  		      (setf (eltgli ptr 2) (^z))
		     (error "OBSERVER Z OF ~S: FOREIGN-PTR is NIL (Foreign memory  
(Continue reading)

Ken Tilton | 30 Aug 15:03 2007
Picon

Re: Problem with defmd and dependency ...

Frank Goenninger wrote:
> Hi Kenny (and all on the list):
> 
> I have a simple defmd:
> 
> (defmd gnc-point ()
>     (x (c-in 0))
>     (y (c-in 0))
>     (z (c-in 0))
>     (foreign-ptr (c_? (let ((ptr (or (^foreign-ptr) (fgn-alloc 'glInt  3 
> :gnc-point))))
>                                (when ptr
>                                    (setf (eltgli ptr 0) (^x))
>                                  (setf (eltgli ptr 1) (^y))
>                                  (setf (eltgli ptr 2) (^z)))
>                                  ptr))))
> 
> 
> This is a model for a point ( x | y | z ) and a foreign object  pointer. 
> The pointer shall be set to a an FFI memory pointer (via  CFFI) when the 
> instance is created. Also, the elements of the memory  array (which is 3 
> glInt, this being three OpenGL Integers) shall be  updated when any of 
> the coordinates x y z is changed...
> 
> I get  x, y, and z updated but the foreign-ptr remains NIL ... What  am 
> I doing wrong ???

Sorry, I was out for the day at the US Open Tennis tournament.

I am just going to throw notes over the wall cuz no time to dig...
(Continue reading)

Ken Tilton | 30 Aug 15:10 2007
Picon

Re: Problem with defmd and dependency ...

Frank Goenninger wrote:
> Correct problem case:
> 
> I defined the foreign-ptr cell as lazy (as :until-asked) for a  reason 
> ... ->

Lazy is one good step if you have confidence a slot will not get read 
(asked) until its dependencies will be in place.

> 
> 0>  7612 calculating cell ~a appears in call stack: ~a dirty=0/ 
> foreign-ptr/gnc-point0] dirty=0/foreign-ptr/gnc-point0]
> (dirty=0/foreign-ptr/gnc-point0])
> 
> ... landing in a (break) ...
> 
> Ok. So I am basically looking for an idiom on how to avoid the  
> circularity. I sense there is a simple solution

.cache or .cache., I forget. :)

kt

Gmane