Changeset 14221


Ignore:
Timestamp:
Aug 26, 2010, 9:10:16 AM (9 years ago)
Author:
arthur
Message:

add-subviews and remove-subviews do their work on main thread, obj-C isFlipped methods test for failures characteristic of the SLOT-VECTOR shortness problem, and write a message if EASYGUI::*REPORT-FLIPPING-ERRORS* is non-NIL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/examples/cocoa/easygui/views.lisp

    r13908 r14221  
    5454The same effect can be obtained for an individual use of With-Focused-View by giving
    5555:WITHOUT-FLUSH as the first form in its body.")
     56
     57(defvar *report-flipping-errors* nil "
     58This variable determines whether messages are printed when an error occurs inside the
     59Obj-C methods named 'isFlipped'. Intermittent errors have been happening, having
     60something to do with SLOT-VECTORs of instances of NSObjects not having the expected
     61number of elements. When it is evident that these problems have been fixed, this
     62variable should be removed and the two isFlipped methods redefined. For now, it is
     63useful to have a way to tell that such errors have occurred and carry on regardless.")
    5664
    5765(defun ns-point-from-point (eg-point)  ;; probably belongs in new-cocoa-bindings.lisp
     
    890898
    891899(defmethod add-1-subview ((view view) (super-view view))
    892   (running-on-this-thread ()
    893     (setf (slot-value view 'parent) super-view)
    894     (push view (slot-value super-view 'subviews))
    895     (dcc (#/addSubview: (cocoa-ref super-view) (cocoa-ref view)))))
     900  (setf (slot-value view 'parent) super-view)
     901  (push view (slot-value super-view 'subviews))
     902  (dcc (#/addSubview: (cocoa-ref super-view) (cocoa-ref view))))
    896903
    897904(defun add-subviews (superview subview &rest subviews)
    898   (setf (view-subviews-busy superview) t)
    899   (add-1-subview subview superview)
    900   (dolist (subview subviews)
    901     (add-1-subview subview superview))
    902   (set-needs-display superview t)
    903   (setf (view-subviews-busy superview) nil)
     905  (running-on-main-thread ()
     906     (setf (view-subviews-busy superview) t)
     907     (add-1-subview subview superview)
     908     (dolist (subview subviews)
     909       (add-1-subview subview superview))
     910     (set-needs-display superview t)
     911     (setf (view-subviews-busy superview) nil))
    904912  superview)
    905913
     
    918926
    919927(defun remove-subviews (superview subview &rest subviews)
    920   (setf (view-subviews-busy superview) t)
    921   (remove-1-subview subview superview)
    922   (dolist (subview subviews)
    923     (remove-1-subview subview superview))
    924   (set-needs-display superview t)
    925   (setf (view-subviews-busy superview) nil)
     928  (running-on-main-thread ()
     929    (setf (view-subviews-busy superview) t)
     930    (remove-1-subview subview superview)
     931    (dolist (subview subviews)
     932      (remove-1-subview subview superview))
     933    (set-needs-display superview t)
     934    (setf (view-subviews-busy superview) nil))
    926935  superview)
    927936
     
    10081017         
    10091018(objc::defmethod (#/isFlipped :<BOOL>) ((self cocoa-drawing-view))
     1019  (handler-case (if (slot-value self 'flipped) #$YES #$NO)
     1020    (simple-error (condition)
     1021      (when *report-flipping-errors* (format t "'isFlipped ~s' ignores error~%" self))
     1022      (values (if *screen-flipped* #$YES #$NO) condition))))
     1023
     1024(objc::defmethod (#/isFlipped :<BOOL>) ((self cocoa-contained-view))
     1025  (handler-case (if (slot-value self 'flipped) #$YES #$NO)
     1026    (simple-error (condition)
     1027      (when *report-flipping-errors* (format t "'isFlipped ~s' ignores error~%" self))
     1028      (values (if *screen-flipped* #$YES #$NO) condition))))
     1029
     1030#| ------------
     1031When the problem of wrong-size SLOT-VECTORs is clearly gone, the two definitions above
     1032should be replaced with these simpler versions:
     1033(objc::defmethod (#/isFlipped :<BOOL>) ((self cocoa-drawing-view))
    10101034  (if (slot-value self 'flipped) #$YES #$NO))
    10111035
    10121036(objc::defmethod (#/isFlipped :<BOOL>) ((self cocoa-contained-view))
    10131037  (if (slot-value self 'flipped) #$YES #$NO))
     1038------------ |#
    10141039
    10151040(defmethod initialize-view :after ((view drawing-view))
Note: See TracChangeset for help on using the changeset viewer.