Fix the crash in the watch tab

Summary:
BUG:

{F158264042}

Context: The code entered an infinite loop till it crashed. In the implementation of `- (SKSearchResultNode *)searchForQuery:(NSString *)query fromNode:(id)node withElementsAlreadyAdded:(NSMutableSet<NSString *> *)alreadyAdded`, we recurse through the child. In the case when the view was `CKRootComponent` it created a `SKComponentLayoutWrapper` in the call to `[descriptor childForNode: node atIndex: i];`. This wrapper's descriptor used to return the very same view from which it was created when it's children were asked. So this led to an infinite loop.

Reviewed By: kfirapps

Differential Revision: D15266478

fbshipit-source-id: 8035209746b7cb4b8773e2fcbdd4c0a148191304
This commit is contained in:
Pritesh Nandgaonkar
2019-05-10 09:50:21 -07:00
committed by Facebook Github Bot
parent d6ccf74c37
commit 821232a9c6

View File

@@ -86,7 +86,7 @@
- (id)childForNode:(SKComponentLayoutWrapper *)node atIndex:(NSUInteger)index {
if (node.children.size() == 0) {
return node.component.viewContext.view;
return nil;
}
return node.children[index];
}