Faculty of Information Technology
Software Engineering Group

Ticket #108: libtool_fix_1_of_3_rev_c95ae929a0b1_Issue__108__Fixed_bug_causing_method_selection_loss_in_some_cases.patch

File libtool_fix_1_of_3_rev_c95ae929a0b1_Issue__108__Fixed_bug_causing_method_selection_loss_in_some_cases.patch, 5.7 KB (added by Jan Vrany, 6 years ago)
  • Tools__MethodList.st

    # HG changeset patch
    # User Jan Vrany <jan.vrany@fit.cvut.cz>
    # Date 1508108210 -3600
    #      Sun Oct 15 23:56:50 2017 +0100
    # Branch jv
    # Node ID c95ae929a0b1e748f2d2402f9ec89a742834cad5
    # Parent  efa1e403da80d56902d761ef858f8d5e0c41346b
    Issue #108: Fixed bug causing method selection loss in some cases
    
    ...when method breakpoint was installed / removed. When this happens
    and the method is selected in a browser, the selection collection
    is first update in-place and then dependents are updated.
    
    The problem was. however, that if the selection was not an `OrderedCollection`,
    the selection was not updated in place due to:
    
        selection := selection asOrderedCollection.
    
    Subsequent notification of dependents causes selection refetch from
    the selection collection which still contained original method, not
    the wrapped method now installed in a class so selection was removed.
    
    This commit fixes this problem.
    
    See https://swing.fit.cvut.cz/projects/stx-jv/ticket/108
    
    diff -r efa1e403da80 -r c95ae929a0b1 Tools__MethodList.st
    a b  
    369369
    370370delayedUpdate:something with:aParameter from:changedObject
    371371    |cls clsName sel oldMethod newMethod methods newSelection
    372      selectionHolder selection needSelectionChange|
     372     selection needSelectionChange|
    373373
    374     selectionHolder := self selectedMethods.
    375     selection := selectionHolder value.
     374    selection := self selectionHolder value.
    376375
    377376    changedObject == environment ifTrue:[
    378377        classes notNil ifTrue:[
     
    415414                         however, ensure that the refs to the old method are updated
    416415                        "
    417416                        methods := selection.
    418                         methods size > 0 ifTrue:[
     417                        selection notEmpty ifTrue:[
    419418                            (methods includesIdentical:oldMethod) ifTrue:[
    420419                                needSelectionChange := true.
    421420                            ]
     
    424423                        lastSelectedMethods notNil ifTrue:[
    425424                            lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
    426425                        ].
    427                         methods size > 0 ifTrue:[
     426                        selection notEmpty ifTrue:[
    428427                            methods := methods asOrderedCollection.
    429428                            methods replaceAllIdentical:oldMethod with:newMethod.
    430429                        ].
     
    498497
    499498                (something == #methodTrap) ifTrue:[
    500499                    newMethod isWrapped ifTrue:[
    501                         oldMethod := newMethod originalMethod
     500                        oldMethod := newMethod originalMethod.
    502501                    ] ifFalse:[
    503                         selection size > 0 ifTrue:[
     502                        selection notEmpty ifTrue:[
    504503                            oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil.
    505504                        ]
    506505                    ].
    507506
    508                     selection size > 0 ifTrue:[
     507                    selection notEmpty ifTrue:[
    509508                        (selection includesIdentical:oldMethod) ifTrue:[
    510509                            needSelectionChange := true.
    511510                        ]
     
    514513                    lastSelectedMethods notNil ifTrue:[
    515514                        lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
    516515                    ].
    517                     selection size > 0 ifTrue:[
    518                         selection := selection asOrderedCollection.
    519                         selection replaceAllIdentical:oldMethod with:newMethod.
     516                    selection notEmpty ifTrue:[
     517                        "/ Used to be:
     518                        "/
     519                        "/     selection := selection asOrderedCollection,
     520                        "/     selection replaceAllIdentical:oldMethod with:newMethod.
     521                        "/
     522                        "/ but that's WRONG!! If the selection is not an ordered collection,
     523                        "/ then asOrderedCollection would create new collection noone else
     524                        "/ references and thus the replace is useless. If the selection
     525                        "/ is already an OrderedCollection, then #asOrderedCollection is
     526                        "/ itself useless.
     527                        "/
     528                        "/ The former case (when selection was for example an array) caused
     529                        "/ selection loss on some cases, hard to chase down!!
     530                        selection isSequenceable ifTrue:[
     531                            selection replaceAllIdentical:oldMethod with:newMethod.
     532                        ] ifFalse:[
     533                            "/ Now, are we sure selection is always a sequenceable?
     534                            "/ I (JV) am not sure so handle (Identity)Set cases too:
     535                            self breakPoint: #jv. 
     536                            (selection includesIdentical: oldMethod) ifTrue:[
     537                                selection removeIdentical: oldMethod.
     538                                selection add: newMethod.
     539                            ].
     540                        ].
    520541                    ].
    521542                    needSelectionChange == true ifTrue:[
    522543                        selectionHolder changed.
     
    709730
    710731    "Created: / 05-02-2000 / 13:42:14 / cg"
    711732    "Modified: / 05-06-2012 / 23:47:15 / cg"
    712     "Modified: / 24-08-2013 / 00:41:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     733    "Modified: / 15-10-2017 / 23:49:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    713734!
    714735
    715736selectedMethodsChanged