class: DeviceWorkstation
changed: #removeKnownView:withId:
allow a ni vie argument
--- a/DeviceWorkstation.st Mon Mar 17 10:33:20 2014 +0100
+++ b/DeviceWorkstation.st Mon Mar 17 20:01:42 2014 +0100
@@ -7634,87 +7634,93 @@
!
removeKnownView:aView withId:aViewId
- "remove aView from the list of known views/id's."
-
- |index wasBlocked nV nI n dstIdx v id newSize|
+ "remove aView from the list of known views/id's.
+ One of aView of aViewId may be nil. The nil one is computed from the other variable."
+
+ |index wasBlocked nV nI n dstIdx v id newSize viewToRemove|
lastId := nil.
lastView := nil.
focusView == aView ifTrue:[
- focusView := nil
+ focusView := nil
].
knownViews notNil ifTrue:[
- wasBlocked := OperatingSystem blockInterrupts.
-
- index := 0.
- aViewId notNil ifTrue:[
- idToTableIndexMapping notNil ifTrue:[
- index := idToTableIndexMapping at:aViewId ifAbsent:0.
- ]
- ].
- index == 0 ifTrue:[
- aView notNil ifTrue:[
- index := knownViews identityIndexOf:aView.
- ].
- ].
-
- index ~~ 0 ifTrue:[
- idToTableIndexMapping notNil ifTrue:[
- aViewId notNil ifTrue:[
- idToTableIndexMapping removeKey:aViewId ifAbsent:nil
- ] ifFalse:[
- id := knownIds at:index.
- id notNil ifTrue:[
- idToTableIndexMapping removeKey:id ifAbsent:nil.
- ]
- ]
- ].
- knownViews at:index put:nil.
- knownIds at:index put:nil.
- lastId := nil.
- lastView := nil.
- ].
-
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-
- (aView notNil and:[aView isTopView]) ifTrue:[
- "/ check for sparsely filled knownViews - array
- wasBlocked := OperatingSystem blockInterrupts.
- n := 0.
- knownViews do:[:v |
- (v notNil and:[v ~~ 0]) ifTrue:[
- n := n + 1
- ].
- ].
- n < (knownViews size * 2 // 3) ifTrue:[
- newSize := n * 3 // 2.
- newSize > 50 ifTrue:[
- nV := WeakArray new:newSize.
- nI := Array new:newSize.
- dstIdx := 1.
- 1 to:knownViews size do:[:srcIdx |
- v := knownViews at:srcIdx.
- (v notNil and:[v ~~ 0]) ifTrue:[
- nV at:dstIdx put:v.
- nI at:dstIdx put:(knownIds at:srcIdx).
- dstIdx := dstIdx + 1.
- ].
- ].
- idToTableIndexMapping := nil.
- knownViews := nV.
- knownIds := nI.
- idToTableIndexMapping := Dictionary new.
- knownIds keysAndValuesDo:[:idx :id |
- id notNil ifTrue:[
- idToTableIndexMapping at:id put:idx
- ]
- ].
- ].
- ].
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
- self checkForEndOfDispatch.
- ].
+ wasBlocked := OperatingSystem blockInterrupts.
+
+ viewToRemove := aView.
+ index := 0.
+ aViewId notNil ifTrue:[
+ idToTableIndexMapping notNil ifTrue:[
+ index := idToTableIndexMapping at:aViewId ifAbsent:0.
+ ]
+ ].
+ index == 0 ifTrue:[
+ viewToRemove notNil ifTrue:[
+ index := knownViews identityIndexOf:viewToRemove.
+ ].
+ ] ifFalse:[
+ viewToRemove isNil ifTrue:[
+ viewToRemove := knownViews at:index ifAbsent:nil.
+ ].
+ ].
+
+ index ~~ 0 ifTrue:[
+ idToTableIndexMapping notNil ifTrue:[
+ aViewId notNil ifTrue:[
+ idToTableIndexMapping removeKey:aViewId ifAbsent:nil
+ ] ifFalse:[
+ id := knownIds at:index.
+ id notNil ifTrue:[
+ idToTableIndexMapping removeKey:id ifAbsent:nil.
+ ]
+ ]
+ ].
+ knownViews at:index put:nil.
+ knownIds at:index put:nil.
+ lastId := nil.
+ lastView := nil.
+ ].
+
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+
+ (viewToRemove notNil and:[viewToRemove isTopView]) ifTrue:[
+ "/ check for sparsely filled knownViews - array
+ wasBlocked := OperatingSystem blockInterrupts.
+ n := 0.
+ knownViews do:[:v |
+ (v notNil and:[v ~~ 0]) ifTrue:[
+ n := n + 1
+ ].
+ ].
+ n < (knownViews size * 2 // 3) ifTrue:[
+ newSize := n * 3 // 2.
+ newSize > 50 ifTrue:[
+ nV := WeakArray new:newSize.
+ nI := Array new:newSize.
+ dstIdx := 1.
+ 1 to:knownViews size do:[:srcIdx |
+ v := knownViews at:srcIdx.
+ (v notNil and:[v ~~ 0]) ifTrue:[
+ nV at:dstIdx put:v.
+ nI at:dstIdx put:(knownIds at:srcIdx).
+ dstIdx := dstIdx + 1.
+ ].
+ ].
+ idToTableIndexMapping := nil.
+ knownViews := nV.
+ knownIds := nI.
+ idToTableIndexMapping := Dictionary new.
+ knownIds keysAndValuesDo:[:idx :id |
+ id notNil ifTrue:[
+ idToTableIndexMapping at:id put:idx
+ ]
+ ].
+ ].
+ ].
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ self checkForEndOfDispatch.
+ ].
]
"Created: 22.3.1997 / 14:56:20 / cg"
@@ -8315,11 +8321,11 @@
!DeviceWorkstation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.606 2014-03-16 21:17:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.607 2014-03-17 19:01:42 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.606 2014-03-16 21:17:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.607 2014-03-17 19:01:42 stefan Exp $'
! !