Break API compatibility for qt:with-app and qt:exec & spellcheck
src/application.lisp
Wed Jul 1 12:58:06 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Break API compatibility for qt:with-app and qt:exec & spellcheck
--- old-qt.gui/src/application.lisp 2014-10-30 07:46:02.000000000 +0100
+++ new-qt.gui/src/application.lisp 2014-10-30 07:46:02.000000000 +0100
@@ -1,7 +1,5 @@
(in-package :cl-smoke.qt-impl)
-(declaim (optimize (debug 3)))
-
(defvar *app*)
(defvar *widgets* nil)
(defvar qt:*exec-p* t
@@ -19,7 +17,6 @@
"Returns t when the APPLICATION object exists and nil otherwise."
(boundp '*app*))
-
(let ((argv (null-pointer))
(argc (null-pointer)))
(declare (cffi:foreign-pointer argv argc))
@@ -69,7 +66,7 @@
(trivial-garbage:cancel-finalization widget)))
(cxx:quit (qt:app))
(setf *widgets* nil)
- ;; Call the destructer; -> destructed callback is called,
+ ;; Call the destructor; -> destructed callback is called,
;; (~QApplication() is virtual) which takes care of cleanup
;; on the Lisp side.
(smoke::delete-pointer (smoke::pointer (qt:app)) (class-of (qt:app)))
@@ -84,37 +81,45 @@
(when ,cleanup-p
,remove-app)))))
-(defmacro qt:with-app (&body body)
+(defmacro qt:with-app (options &body body)
"Ensures that a APPLICATION instance exists,
evaluates BODY and executes the APPLICATION instance after BODY.
The instance can be accessed with:
-APP.
+QT:APP.
Can be nested.
When a APPLICATION was created, it will be deleted when returning
from BODY."
+ (assert (null options)
+ (options)
+ "Currently no options can be passed to QT:WITH-APP.")
`(with-application ((cl-smoke.qt-impl::ensure-app 'qt:application) (kill-app))
- ,@body))
+ ,@body))
-(defmacro qt:with-core-app (&body body)
+(defmacro qt:with-core-app (options &body body)
+ (assert (null options)
+ (options)
+ "Currently no options can be passed to QT:WITH-CORE-APP.")
`(with-application ((cl-smoke.qt-impl::ensure-app 'qt:core-application) (kill-app))
- ,@body))
+ ,@body))
-
-(defun qt:exec (&rest widgets)
- "Executes APP."
- (setf *widgets* (append widgets *widgets*))
- (when qt:*exec-p*
- (restart-bind ((qt::abort-app #'(lambda ()
- (cxx:quit (qt:app))
- (invoke-restart (find-restart 'continue)))
- :report-function
- #'(lambda (stream)
- (format stream "Return from the application event loop."))
- :test-function
- #'(lambda (condition)
- (declare (ignore condition))
- (and (qt:app-p)
- (find-restart 'continue)))))
- (cxx:exec (qt:app)))))
+(defun qt:exec ()
+ "Executes APP. When QT:*EXEC-P* is false it returns immediately
+and transfers the ownership of the top-level widgets to the qt:application
+instance."
+ (if qt:*exec-p*
+ (restart-bind ((qt::abort-app #'(lambda ()
+ (cxx:quit (qt:app))
+ (invoke-restart (find-restart 'continue)))
+ :report-function
+ #'(lambda (stream)
+ (format stream "Return from the application event loop."))
+ :test-function
+ #'(lambda (condition)
+ (declare (ignore condition))
+ (and (qt:app-p)
+ (find-restart 'continue)))))
+ (cxx:exec (qt:app)))
+ (when (typep (qt:app) 'qt:application)
+ (setf *widgets* (qt:application.top-level-widgets)))))