Sun May 24 16:30:31 CEST 2009 Tobias Rautenkranz * Cleanup app in with-app diff -rN -u old-qt.gui/src/application.lisp new-qt.gui/src/application.lisp --- old-qt.gui/src/application.lisp 2014-10-30 07:49:56.000000000 +0100 +++ new-qt.gui/src/application.lisp 2014-10-30 07:49:56.000000000 +0100 @@ -9,7 +9,8 @@ "Returns the APPLICATION (or CORE-APPLICATION) object, within a WITH-APP." (assert (app-p) - (*app*)) + (*app*) + "No application.") *app*) (defun app-p () @@ -40,33 +41,32 @@ not of type ~A." (app) (find-class application)) (values (app) nil)) (progn -; (assert (null-pointer-p (smoke::pointer (core-application.instance)))) - (foreign-free argv) - (foreign-free argc) + ;(assert (null-pointer-p (smoke::pointer (core-application.instance)))) + (foreign-free argv) + (foreign-free argc) (setf argv (foreign-alloc :string :initial-contents args)) (setf argc (foreign-alloc :int :initial-element (length args))) - (values (qt:new "QApplication" "QApplication$?" argc argv) t)))) + (values (make-instance 'qt:application :args (list argc argv)) t)))) (defun kill-app () (cxx:quit (app)) - (when (typep (app) (find-class 'qt:application)) - (application.close-all-windows)) +; (when (typep (app) (find-class 'qt:application)) +; (application.close-all-windows)) (setf *widgets* nil) (trivial-garbage:cancel-finalization (app)) - ;(smoke::remove-object (smoke::pointer (app))) - (smoke::delete-pointer (smoke::pointer (app)) (class-of (app))) + (smoke::remove-object (smoke::pointer (app))) + ;; FIXME leak memory or memory fault! + ;(smoke::delete-pointer (smoke::pointer (app)) (class-of (app))) (setf (slot-value (app) 'pointer) (null-pointer)) -; (foreign-free argc) - (setf argc (null-pointer)) -; (foreign-free argv) - (setf argv (null-pointer)) (makunbound '*app*))) (defmacro with-application ((ensure-app remove-app) &body body) - `(progn (setf *app* ,ensure-app) - (unwind-protect - (progn - ,@body)))) + (let ((cleanup-p (gensym))) + `(multiple-value-bind (*app* ,cleanup-p) ,ensure-app + (unwind-protect + (progn ,@body) + (when ,cleanup-p + ,remove-app))))) (defmacro with-app (&body body) "Ensures that a APPLICATION instance exists, diff -rN -u old-qt.gui/src/package.lisp new-qt.gui/src/package.lisp --- old-qt.gui/src/package.lisp 2014-10-30 07:49:56.000000000 +0100 +++ new-qt.gui/src/package.lisp 2014-10-30 07:49:56.000000000 +0100 @@ -1,7 +1,6 @@ (defpackage :qt (:use :cl :smoke :cffi :bordeaux-threads :cxx-support) - (:export #:new - #:call + (:export #:call #:app #:app-p diff -rN -u old-qt.gui/src/qt.lisp new-qt.gui/src/qt.lisp --- old-qt.gui/src/qt.lisp 2014-10-30 07:49:56.000000000 +0100 +++ new-qt.gui/src/qt.lisp 2014-10-30 07:49:56.000000000 +0100 @@ -34,8 +34,5 @@ (eval-when (:load-toplevel :compile-toplevel :execute) (use-foreign-library libqt-smoke-extra)) -(defun new (class-name method-name &rest args) - (apply #'new-object (smoke::binding *qt-smoke*) class-name method-name args)) - (defun static-call (class-name method-name &rest args) (apply #'smoke::static-call *qt-smoke* class-name method-name args))