# 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
|
|
369 | 369 | |
370 | 370 | delayedUpdate:something with:aParameter from:changedObject |
371 | 371 | |cls clsName sel oldMethod newMethod methods newSelection |
372 | | selectionHolder selection needSelectionChange| |
| 372 | selection needSelectionChange| |
373 | 373 | |
374 | | selectionHolder := self selectedMethods. |
375 | | selection := selectionHolder value. |
| 374 | selection := self selectionHolder value. |
376 | 375 | |
377 | 376 | changedObject == environment ifTrue:[ |
378 | 377 | classes notNil ifTrue:[ |
… |
… |
|
415 | 414 | however, ensure that the refs to the old method are updated |
416 | 415 | " |
417 | 416 | methods := selection. |
418 | | methods size > 0 ifTrue:[ |
| 417 | selection notEmpty ifTrue:[ |
419 | 418 | (methods includesIdentical:oldMethod) ifTrue:[ |
420 | 419 | needSelectionChange := true. |
421 | 420 | ] |
… |
… |
|
424 | 423 | lastSelectedMethods notNil ifTrue:[ |
425 | 424 | lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
426 | 425 | ]. |
427 | | methods size > 0 ifTrue:[ |
| 426 | selection notEmpty ifTrue:[ |
428 | 427 | methods := methods asOrderedCollection. |
429 | 428 | methods replaceAllIdentical:oldMethod with:newMethod. |
430 | 429 | ]. |
… |
… |
|
498 | 497 | |
499 | 498 | (something == #methodTrap) ifTrue:[ |
500 | 499 | newMethod isWrapped ifTrue:[ |
501 | | oldMethod := newMethod originalMethod |
| 500 | oldMethod := newMethod originalMethod. |
502 | 501 | ] ifFalse:[ |
503 | | selection size > 0 ifTrue:[ |
| 502 | selection notEmpty ifTrue:[ |
504 | 503 | oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil. |
505 | 504 | ] |
506 | 505 | ]. |
507 | 506 | |
508 | | selection size > 0 ifTrue:[ |
| 507 | selection notEmpty ifTrue:[ |
509 | 508 | (selection includesIdentical:oldMethod) ifTrue:[ |
510 | 509 | needSelectionChange := true. |
511 | 510 | ] |
… |
… |
|
514 | 513 | lastSelectedMethods notNil ifTrue:[ |
515 | 514 | lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
516 | 515 | ]. |
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 | ]. |
520 | 541 | ]. |
521 | 542 | needSelectionChange == true ifTrue:[ |
522 | 543 | selectionHolder changed. |
… |
… |
|
709 | 730 | |
710 | 731 | "Created: / 05-02-2000 / 13:42:14 / cg" |
711 | 732 | "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>" |
713 | 734 | ! |
714 | 735 | |
715 | 736 | selectedMethodsChanged |