Skip to content

Commit 7d5767f

Browse files
committed
Fix the bug of infinite loop in certain condition causing crash
1 parent 8404100 commit 7d5767f

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/Pyramid-Bloc/PyramidEditElementTreeDragAndDropPlugin.class.st

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Class {
1010
'editor',
1111
'navigationPlugin',
1212
'navigationSelectionPanel',
13-
'navigationPresenter'
13+
'navigationPresenter',
14+
'canMoveCollection'
1415
],
1516
#category : #'Pyramid-Bloc-plugin-edit-element-tree'
1617
}
@@ -47,24 +48,28 @@ PyramidEditElementTreeDragAndDropPlugin >> canMoveSelectedElement: anArrayOfElem
4748
| canMove |
4849
canMove := true.
4950

51+
canMoveCollection removeAll.
52+
5053
anArrayOfElementDragged do: [ :element |
5154
aElementTarget = element ifTrue: [ ^ canMove := false ] ].
5255

53-
canMove := (self checkParentOfTarget: aElementTarget
54-
draggedBlElement: anArrayOfElementDragged).
56+
self checkParentOfTarget: aElementTarget
57+
draggedBlElement: anArrayOfElementDragged.
58+
59+
canMoveCollection do: [ :boolean | boolean ifFalse: [ canMove := false ] ].
5560

56-
^ canMove
61+
^ canMove
5762
]
5863

5964
{ #category : #testing }
6065
PyramidEditElementTreeDragAndDropPlugin >> checkParentOfTarget: aElementTarget draggedBlElement: anArrayOfElementDragged [
61-
62-
aElementTarget hasParent
66+
67+
aElementTarget hasParent
6368
ifTrue: [ anArrayOfElementDragged do: [ :element | (aElementTarget parent = element)
64-
ifTrue: [ ^ false ]
65-
ifFalse: [ ^ (self checkParentOfTarget: (aElementTarget parent)
66-
draggedBlElement: anArrayOfElementDragged). ] ] ]
67-
ifFalse: [ ^ true ]
69+
ifTrue: [ canMoveCollection add: false ]
70+
ifFalse: [ self checkParentOfTarget: (aElementTarget parent)
71+
draggedBlElement: anArrayOfElementDragged ] ] ]
72+
ifFalse: [ canMoveCollection add: true ]
6873

6974
]
7075

@@ -89,7 +94,7 @@ PyramidEditElementTreeDragAndDropPlugin >> editor [
8994
{ #category : #initialization }
9095
PyramidEditElementTreeDragAndDropPlugin >> initialize [
9196

92-
"Do nothing"
97+
canMoveCollection := OrderedCollection new
9398
]
9499

95100
{ #category : #actions }

0 commit comments

Comments
 (0)