sø., 15.03.2009 kl. 16.30 +0100, skrev Ramarren:
> On Sun, Mar 15, 2009 at 3:51 PM, Johan Ur Riise <[email protected]> wrote:
> > #|
> > (cells-gtk:start-app 'my-app)
> > |#
> >
> > #|
> > (cgtk:with-widget (w :statebar) (setf (busy w) t))
> > |#
>
> On my system at least cells-gtk:start-app blocks the repl, so how
> would you set the widget after that?
I used slime, and executed one in the repl and one by C-x C-e in the
source window. That means two threads, but I also tried enclosing the
setf in cells-gtk:with-gdk-threads, with the same result
> When using cells-gtk:start-win it
> closes normally in both cases.
That is a lead, could be threads problem. Using start-win does not make
a difference.
> Anyway, as far as I can tell, cells have no thread-safety at all. The
> GTK parts do have locks to guarantee at most one thread accesses them
> at a time, but as far as I can tell the cells system doesn't, and it
> is quite possible to cause two conflicting datapulses, which means
> that all cell access, even with models completely separate from
> cells-gtk, have to be done through cells-gtk:with-gdk-threads. But
> this doesn't seem to related to your problem.
I tried to completely eliminate threads by creating a closure, putting
it on a global variable and starting it by way of cgtk:timeout-add.
Also I tried to do it without slime.
Complete program:
(defparameter *run-in-main-thread* nil)
(defparameter *lock* (sb-thread:make-mutex))
(defun run-in-main ()
(let ((func (sb-thread:with-mutex (*lock*) (pop
*run-in-main-thread*))))
(when func (funcall func)
(format t "called~%") (terpri)))
t)
(cells:defmodel statebar (cgtk:hbox)
((busy :accessor busy :initform (cells:c-in nil)))
(:default-initargs
:md-name :statebar
:kids (cgtk:kids-list?
(cgtk:mk-label :text (if (busy cells:self) "Busy"
"NotBusy"))
(cgtk:mk-label :markup (cgtk:with-markup (:background (if
(busy cells:self) :yellow :brown))
(if (busy cells:self) "Busy" "NotBusy"))))))
(cells:defmodel my-app (cells-gtk:gtk-app)
()
(:default-initargs
:kids (cells:c? (cells:the-kids
(cells-gtk:mk-vbox
:kids (cells-gtk:kids-list?
(make-instance 'statebar :fm-parent
cells:*parent*)))))))
(defmethod initialize-instance :after ((self my-app) &rest initargs &key
&allow-other-keys)
(declare (ignore initargs))
(cgtk:timeout-add 50 #'run-in-main))
The error is now slightly different. I get an error saying something
about opengl and an error dialog when I try to close the window, and the
dialog says
"Lisp Error: #<CELLS::C-LINK {C02D721}> cannot be printed readably.
Recklessly continue?"
Here is the console output.
ri...@morr:~/prg/tracklog$ rlwrap sbcl --core sbclgtk
This is SBCL 1.0.26.1, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (load (compile-file "statebarex"))
; compiling file "/home/riise/prg/tracklog/statebarex.lisp" (written 15
MAR 2009 08:40:40 PM):
; compiling (DEFPARAMETER *RUN-IN-MAIN-THREAD* ...)
; compiling (DEFPARAMETER *LOCK* ...)
; compiling (DEFUN RUN-IN-MAIN ...)
; compiling (CELLS:DEFMODEL STATEBAR ...)
; compiling (CELLS:DEFMODEL MY-APP ...)
; compiling (DEFMETHOD INITIALIZE-INSTANCE ...)
; /home/riise/prg/tracklog/statebarex.fasl written
; compilation finished in 0:00:00.211
T
* (sb-thread:make-thread (lambda () (cells-gtk:start-win 'my-app)))
#<SB-THREAD:THREAD RUNNING {BFFA4C9}>
* libGL error: open DRM failed (Operation not permitted)
libGL error: reverting to (slow) indirect rendering
'a
"----------UTILSRESET----------------------------------"
A
* (sb-thread:with-mutex (*lock*) (push (lambda () (cgtk:with-widget
(w :statebar) (setf (busy w) t))) *run-in-main-thread*))
(#<FUNCTION (LAMBDA #) {BF840BD}>)
*
0> c-link> query link :statebar cells-store1 nilcalled
0> c-link> kick link :statebar cells-store1
0> show error message
0> md-awaken :after
1> processing dlg
.2> running dialog
1> showed dialog -9 :no
1> destroying self (not-to-be)
0> >>>> ERROR REPORTING -->
debugger invoked on a PRINT-NOT-READABLE in thread #<THREAD
"gtk-main-thread" RUNNING {C370CC1}>: #<PRINT-NOT-READABLE {C04EDA9}>
cannot be printed readably.
[1]+ Stopped rlwrap sbcl --core sbclgtk
ri...@morr:~/prg/tracklog$ kill %1
[1]+ Stopped rlwrap sbcl --core sbclgtk
ri...@morr:~/prg/tracklog$
_______________________________________________
cells-gtk-devel site list
[email protected]
http://common-lisp.net/mailman/listinfo/cells-gtk-devel