#'END-EVENT-LOOP & cleanup
Sun Jun 7 09:47:13 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* #'END-EVENT-LOOP & cleanup
diff -rN -u old-repl/src/package.lisp new-repl/src/package.lisp
--- old-repl/src/package.lisp 2014-10-30 07:04:34.000000000 +0100
+++ new-repl/src/package.lisp 2014-10-30 07:04:34.000000000 +0100
@@ -6,6 +6,7 @@
(defpackage :cl-smoke.repl
(:use :cl :cxx-support)
(:export #:start-event-loop-in-background
+ #:end-event-loop
#+slime #:start-event-loop-in-repl
#:get-widget
#:locate-widget))
diff -rN -u old-repl/src/repl.lisp new-repl/src/repl.lisp
--- old-repl/src/repl.lisp 2014-10-30 07:04:34.000000000 +0100
+++ new-repl/src/repl.lisp 2014-10-30 07:04:34.000000000 +0100
@@ -25,68 +25,68 @@
(setf *package* (new-package *qt-eval*))
(values-list (result *qt-eval*)))
-(defun end-event-loop ()
- #+slime
- (setf (fdefinition 'swank::eval-region)
- #'(lambda (string)
- (with-input-from-string (stream string)
- (let (- values)
- (loop
- (let ((form (read stream nil stream)))
- (when (eq form stream)
- (fresh-line)
- (finish-output)
- (return (values values -)))
- (setq - form)
- (setq values (multiple-value-list (eval form)))
- (finish-output)))))))
- (cxx:quit (qt:app)))
-
-(defun start-event-loop-in-background ()
- "Starts the QApplication event loop in a new thread and
+(let ((eval-region-orig))
+ (defun end-event-loop ()
+ #+slime
+ (progn
+ (assert eval-region-orig)
+ (setf (fdefinition 'swank::eval-region)
+ eval-region-orig)
+ (setf eval-region-orig nil))
+ (cxx:quit (qt:app)))
+ (defun start-event-loop-in-background ()
+ "Starts the QApplication event loop in a new thread and
sends the forms entered at the REPL to this thread to be evaluated."
- ;; Like eval-region of Slimes swank.lisp
- #+slime
- (setf (fdefinition 'swank::eval-region)
- #'(lambda (string)
- (with-input-from-string (stream string)
- (let (- values)
- (loop
- (let ((form (read stream nil stream)))
- (when (eq form stream)
- (fresh-line)
- (finish-output)
- (return (values values -)))
- (setq - form)
- (setq values (multiple-value-list (qt-eval form)))
- (finish-output)))))))
- (let ((standard-input *standard-input*)
- (standard-output *standard-output*)
- (debug-io *debug-io*)
- (trace-output *trace-output*)
- (error-output *error-output*)
- (query-io *query-io*)
- (terminal-io *terminal-io*)
- (ready-lock (bt:make-lock))
- (ready (bt:make-condition-variable)))
- (bt:make-thread #'(lambda ()
- #+slime
- (setf *standard-input* standard-input
- *standard-output* standard-output
- *debug-io* debug-io
- *trace-output* trace-output
- *error-output* error-output
- *query-io* query-io
- *terminal-io* terminal-io)
- (qt:with-app
- (qt:application.set-quit-on-last-window-closed nil)
- (setf *qt-eval* (make-instance 'qt-eval))
- (qt:do-delayed-initialize
+ ;; Like eval-region of Slimes swank.lisp
+ #+slime
+ (progn
+ (assert (null eval-region-orig))
+ (setf eval-region-orig
+ #'swank::eval-region)
+ (setf (fdefinition 'swank::eval-region)
+ #'(lambda (string)
+ (with-input-from-string (stream string)
+ (let (- values)
+ (loop
+ (let ((form (read stream nil stream)))
+ (when (eq form stream)
+ (fresh-line)
+ (finish-output)
+ (return (values values -)))
+ (setq - form)
+ (setq values (multiple-value-list (qt-eval form)))
+ (finish-output))))))))
+ (let ((standard-input *standard-input*)
+ (standard-output *standard-output*)
+ (debug-io *debug-io*)
+ (trace-output *trace-output*)
+ (error-output *error-output*)
+ (query-io *query-io*)
+ (terminal-io *terminal-io*)
+ (ready-lock (bt:make-lock))
+ (ready (bt:make-condition-variable)))
+ (bt:make-thread #'(lambda ()
+ #+slime
+ (setf *standard-input* standard-input
+ *standard-output* standard-output
+ *debug-io* debug-io
+ *trace-output* trace-output
+ *error-output* error-output
+ *query-io* query-io
+ *terminal-io* terminal-io)
+ (qt:with-app
+ (qt:application.set-quit-on-last-window-closed nil)
+ (setf *qt-eval* (make-instance 'qt-eval))
+ (qt:do-delayed-initialize
(bt:condition-notify ready))
- (qt:exec)))
- :name "Qt Event Loop")
- (bt:with-lock-held (ready-lock)
- (bt:condition-wait ready ready-lock))))
+ (qt:connect (qt:get-signal (qt:app)
+ "aboutToQuit()")
+ #'(lambda ()
+ (setf *qt-eval* nil)))
+ (qt:exec)))
+ :name "Qt Event Loop")
+ (bt:with-lock-held (ready-lock)
+ (bt:condition-wait ready ready-lock)))))
#+slime
(defun start-event-loop-in-repl ()
@@ -101,10 +101,8 @@
(let ((idle (make-instance 'qt:timer)))
(qt:connect (qt:get-signal idle "timeout()")
#'(lambda ()
- ; (swank::handle-requests swank::*emacs-connection* t)
(swank::process-requests t) ;; it's a wonder this even works!
(sb-impl::serve-event 0.1)))
- ;(curry #'sb-impl::serve-event 0.1))
(cxx:start idle)
(qt:exec)
(format *debug-io* "New-repl end~%"))))