ender2012 / xmlisp

Automatically exported from code.google.com/p/xmlisp
0 stars 0 forks source link

CCL Warnings cause error in appkit thread #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In the appkit thread (i.e., all the event handler code invoked by GUI 
components) any kind of warning, 
including the use the warn function itself, will stop the execution of code. 

What steps will reproduce the problem?

(in-package :ccl)

(in-main-thread ()
               (warn "something fishy")
               (print "post warn")
               nil)

;; with Gary P's macro to run body in the appkit thread:

(defmacro IN-MAIN-THREAD (() &body body)
 (let ((thunk (gensym))
       (done (gensym))
       (result (gensym)))
   `(let ((,done nil)
          (,result nil))
      (flet ((,thunk ()
               (setq ,result (multiple-value-list (progn ,@body))
                     ,done t)))
        (gui::execute-in-gui #',thunk)
        (process-wait "Main thread" #'(lambda () ,done))
        (values-list ,result)))))

What is the expected output? 
- see "something fishy" warning printed in alt console,
- see "post warn" printed in alt console

What do you see instead?
- CCL 1.4 PPC -> Error message in al console: this should not be an error
- other platforms: no output, warning does cause error with no output, code 
following warn is NOT executed

Original issue reported on code.google.com by alex.rep...@gmail.com on 13 May 2010 at 2:40

GoogleCodeExporter commented 8 years ago
simpler test case:

(execute-in-gui 
 #'(lambda () 
     (print "1")
     (warn "2")
     (print "3")))

should print "1"  ... warn "2" ... "3" but will only print "1" and stop with 
error at warn

Original comment by alex.rep...@gmail.com on 13 May 2010 at 3:10

GoogleCodeExporter commented 8 years ago
See http://trac.clozure.com/ccl/ticket/682

Original comment by GailZach...@gmail.com on 13 May 2010 at 4:14

GoogleCodeExporter commented 8 years ago
While the *objc-error-return-condition* fix does work for the two examples 
above it does not for the more importance case of calling a lisp function 
including a warning 
from a objective-c function called from a control.

;; right version

Welcome to Clozure Common Lisp Version 1.6-dev-r13737M-trunk  (DarwinX8632)!

;; changing from warning to error
(setq ccl::*objc-error-return-condition* 'error)

(objc:defmethod (#/invokeLispFunction: :void) ((self ns:ns-application) id)
  (gui::invoke-lisp-function self id))

;; now this works:

(in-package :gui)
#<Package "GUI">
? (execute-in-gui 
 #'(lambda () 
     (print "1")
     (warn "2")
     (print "3")))
"3"

But Currency Converter with a warning does not. Prints "1" then dies with 
error. Sometimes (CCL64) no output from error/warning

(in-package :easygui-demo)

(defclass converter-window (window)
   ()
   (:default-initargs :size (point 383 175)
     :position (point 125 513)
     :title "Currency Converter"
     :resizable-p nil
     :minimizable-p t))

(defmethod initialize-view :after ((cw converter-window))
  (let ((currency-form (make-instance 'form-view
                          :autosize-cells-p t
                          :interline-spacing 9.0
                          :position (point 15 70)                          
                          :size (point 353 90)))
        (convert-button (make-instance 'push-button-view
                           :default-button-p t
                           :text "Convert"
                           :position (point 247 15)))
        (line (make-instance 'box-view
                 :position (point 15 59)
                 :size (point 353 2))))
    (setf (action convert-button)
          #'(lambda ()
              (print "1")
              (warn "2")
              (print "3") ))
    (setf (editable-p (car (last (add-entries currency-form
                                              "Exchange Rate per $1:"
                                              "Dollars to Convert:"
                                              "Amount in other Currency:"))))
          nil)
    (add-subviews cw currency-form line convert-button)
    (window-show cw)))

;(make-instance 'converter-window)

Original comment by alex.rep...@gmail.com on 25 May 2010 at 2:36

GoogleCodeExporter commented 8 years ago
ps. we are reloading views.lisp before loading the example. More importantly, 
we are loading all of our code for 
our examples from scratch after (setq ccl::*objc-error-return-condition* 'error)

Original comment by alex.rep...@gmail.com on 25 May 2010 at 3:01

GoogleCodeExporter commented 8 years ago
It works for me if I also recompile easygui from scratch.

Original comment by GailZach...@gmail.com on 31 May 2010 at 3:40

GoogleCodeExporter commented 8 years ago

Original comment by alex.rep...@gmail.com on 2 Sep 2011 at 5:02