Repository navigation
Commit 39e29bf
andy
Organizer: preserve sibling expand state across tree refresh (#1)
Root-caused a 2013 bug report (verahill.blogspot.com, "creating a new
directory causes all open directories lower in rank to auto-close") that
turned out to still be live: CalcMgr::createResource() calls
p_treeCtrl->refresh(parent), where parent defaults to whatever's
currently selected -- typically the shared parent directory you
right-click to create a new child under, not the new child itself.
refresh() -> loadChildren(node, true) does a full delete-and-rebuild of
*every* direct child of that parent, and freshly-rebuilt tree items
default to collapsed -- so any sibling directory you had open elsewhere
under the same parent silently collapses too, even though nothing about
it actually changed.
Fixed by having refresh() record which children are expanded before the
delete-and-rebuild (keyed by resource URL, since the old wxTreeItemIds
don't survive the rebuild), then re-expanding the matching freshly-built
children afterward. Re-expanding a freshly-built (currently childless)
item triggers the normal wxEVT_TREE_ITEM_EXPANDING handler
(CalcMgr::OnTreectrlItemExpanding), which lazily reloads that child's own
children exactly as if the user had expanded it by hand -- so the whole
previously-expanded branch comes back, not just the top-level node.
This is refresh()'s own general mechanism, not a createResource()-special
case -- fixes the same collapse side effect for all ~13 other call sites
(rename, move, drag-drop, ...), not just resource creation.
Verified via a full local build (organizer links clean); not yet
re-tested live against the exact two-open-directories repro from the
original report.1 parent c66d1e2 commit 39e29bf
1 file changed
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
607 | 609 | | |
608 | 610 | | |
609 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
610 | 641 | | |
611 | 642 | | |
612 | 643 | | |
| |||
616 | 647 | | |
617 | 648 | | |
618 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
619 | 655 | | |
620 | 656 | | |
621 | 657 | | |
| |||
0 commit comments