Delete QPainDevices before the QApplication is destroyed.
Annotate for file src/application.lisp
2010-01-10 tobias 1 (in-package :cl-smoke.qt.gui)
2009-04-05 tobias 2
17:56:16 ' 3 (defvar *widgets* nil)
' 4
2010-01-25 tobias 5 (defmethod cl-smoke.qt.core:delete-app :around ((application qt:application))
2010-01-10 tobias 6 (qt:application.close-all-windows)
08:52:49 ' 7 ;; widgets are only valid as long, as an application object
' 8 ;; exists. QApplication::~QApplication() deletes all widgets in
' 9 ;; QApplication::allWidgets().
' 10 ;;
' 11 ;; see: qt4/src/gui/kernel/qapplication.cpp
' 12 (loop for widget across (qt:application.all-widgets) do
' 13 (tg:cancel-finalization widget))
2010-03-10 tobias 14 ;; QPaintDevices are only valid when a application object exists.
17:13:52 ' 15 (loop for object being the hash-values of smoke::*object-map* do
' 16 (when (typep object 'qt:paint-device)
' 17 (delete-object object)))
2010-01-25 tobias 18 ;; Finalize other stuff before deleting the QApplication,
19:09:40 ' 19 ;; e.g. QGraphicsScene
' 20 (tg:gc :full t)
2010-01-10 tobias 21 (call-next-method)
08:52:49 ' 22 (setf *widgets* nil))
2009-04-05 tobias 23
2009-07-01 tobias 24 (defmacro qt:with-app (options &body body)
2009-04-05 tobias 25 "Ensures that a APPLICATION instance exists,
17:56:16 ' 26 evaluates BODY and executes the APPLICATION instance after BODY.
' 27 The instance can be accessed with:
2009-07-01 tobias 28 QT:APP.
2009-04-05 tobias 29
17:56:16 ' 30 Can be nested.
' 31
' 32 When a APPLICATION was created, it will be deleted when returning
' 33 from BODY."
2009-07-01 tobias 34 (assert (null options)
10:58:06 ' 35 (options)
' 36 "Currently no options can be passed to QT:WITH-APP.")
2010-01-23 tobias 37 `(cl-smoke.qt.core:with-application ((cl-smoke.qt.core:ensure-app 'qt:application)
19:48:00 ' 38 (cl-smoke.qt.core:kill-app))
2009-07-01 tobias 39 ,@body))
2009-04-05 tobias 40
2009-07-01 tobias 41 (defun qt:exec ()
10:58:06 ' 42 "Executes APP. When QT:*EXEC-P* is false it returns immediately
' 43 and transfers the ownership of the top-level widgets to the qt:application
' 44 instance."
' 45 (if qt:*exec-p*
' 46 (restart-bind ((qt::abort-app #'(lambda ()
' 47 (cxx:quit (qt:app))
' 48 (invoke-restart (find-restart 'continue)))
' 49 :report-function
' 50 #'(lambda (stream)
' 51 (format stream "Return from the application event loop."))
' 52 :test-function
' 53 #'(lambda (condition)
' 54 (declare (ignore condition))
' 55 (and (qt:app-p)
' 56 (find-restart 'continue)))))
2009-07-03 tobias 57 (let ((qt:*exec-p* nil))
10:14:09 ' 58 (cxx:exec (qt:app))))
2009-07-01 tobias 59 (when (typep (qt:app) 'qt:application)
10:58:06 ' 60 (setf *widgets* (qt:application.top-level-widgets)))))