Solved the bug related to the toggle inspector of iOS
Summary: Before this diff the nodes were not invalidated properly when the new view got added in the hierarchy, due to this there was following bug. https://our.intern.facebook.com/intern/px/p/15RSP Reviewed By: Andrey-Mishanin Differential Revision: D21285438 fbshipit-source-id: b72aa93856688b31296ae1df4f15e128037aa1ca
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d360c95a6d
commit
794d2f282f
@@ -371,6 +371,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)invalidateRootNode {
|
||||
[self invalidateNode:_rootNode];
|
||||
}
|
||||
|
||||
- (void)_reportInvalidatedObjects {
|
||||
NSMutableArray* nodes = [NSMutableArray new];
|
||||
{ // scope mutex acquisition
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
@protocol SKInvalidationDelegate
|
||||
|
||||
- (void)invalidateNode:(id<NSObject>)node;
|
||||
|
||||
- (void)invalidateRootNode;
|
||||
- (void)updateNodeReference:(id<NSObject>)node;
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "SKInvalidation.h"
|
||||
#import "SKSwizzle.h"
|
||||
#import "UIView+SKInvalidation.h"
|
||||
@@ -31,6 +30,14 @@ FB_LINKABLE(UIView_SKInvalidation)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
This function takes in a view and returns true if the view is a UIWindow and its
|
||||
windowLevel is an alert one otherwise it returns false.
|
||||
*/
|
||||
static auto shouldInvalidateRootNode(UIView* view) -> bool {
|
||||
return [view isKindOfClass:[UIWindow class]];
|
||||
}
|
||||
|
||||
- (void)swizzle_setHidden:(BOOL)hidden {
|
||||
[self swizzle_setHidden:hidden];
|
||||
|
||||
@@ -47,7 +54,11 @@ FB_LINKABLE(UIView_SKInvalidation)
|
||||
id<SKInvalidationDelegate> delegate =
|
||||
[SKInvalidation sharedInstance].delegate;
|
||||
if (delegate != nil) {
|
||||
[delegate invalidateNode:view];
|
||||
if (shouldInvalidateRootNode(view.superview)) {
|
||||
[delegate invalidateRootNode];
|
||||
return;
|
||||
}
|
||||
[delegate invalidateNode:view.superview];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +66,10 @@ FB_LINKABLE(UIView_SKInvalidation)
|
||||
id<SKInvalidationDelegate> delegate =
|
||||
[SKInvalidation sharedInstance].delegate;
|
||||
if (delegate != nil && self.superview != nil) {
|
||||
if (shouldInvalidateRootNode(self.superview)) {
|
||||
[delegate invalidateRootNode];
|
||||
return;
|
||||
}
|
||||
[delegate invalidateNode:self.superview];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user