Skip to content

loadKeyPath sometimes gets the root wrong #576

@heacu

Description

@heacu

I won't develop a full test case here, but I can describe the problem and my workaround. Suppose you have a tree where all nodes are loaded lazily. You call loadKeyPath to load the two paths in (1). Results are returned, then filtered or whatever; all good.

  1. /426/5376/872/876/4597, /426/5378/841/843/3103
  2. /426/5378/841/845/3220, /426/5407/851/855/3691

You then call loadKeyPath again to load the two paths in (2). This will cause a "node is null" error. Node 841 is loaded by (1), in order to load its child node 843. Therefore, when loadKeyPath is called with the paths in (2), node 841 has already been loaded and so 845 is added as a key to loadMap. The problem is that node 5407 will also be added as a key to loadMap, since it hasn't been loaded either.

But 845 and 5407 are not children of the same root! So this later code fails:

for(key in loadMap){
    node = root._findDirectChild(key);

My workaround is to replace that code with

for(key in loadMap){
    node = root._findDirectChild(key);
    if (node == null) {
        node = self.getNodeByKey(key);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions