Fix retaining self in block in LogBox impl
Summary: Logbox has a retain cycle (see linked task for my deeper investigation). This diff doesn't fix the retain cycle, but it's just good practice to not retain self strongly in blocks. Changelog: [iOS][Internal] Fix retaining self in block in LogBox implementation Reviewed By: shergin Differential Revision: D20630693 fbshipit-source-id: cf399495e9bcd1917932fcc0e9c9d2d2a32bf6f0
This commit is contained in:
Родитель
faff19a7c6
Коммит
72ac2125bc
|
@ -91,11 +91,16 @@ RCT_EXPORT_MODULE()
|
|||
RCT_EXPORT_METHOD(show)
|
||||
{
|
||||
if (RCTRedBoxGetEnabled()) {
|
||||
__weak RCTLogBox *weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!self->_view) {
|
||||
self->_view = [[RCTLogBoxView alloc] initWithFrame:[UIScreen mainScreen].bounds bridge:self->_bridge];
|
||||
__strong RCTLogBox *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
[self->_view show];
|
||||
if (!strongSelf->_view) {
|
||||
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:[UIScreen mainScreen].bounds bridge:self->_bridge];
|
||||
}
|
||||
[strongSelf->_view show];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -103,8 +108,13 @@ RCT_EXPORT_METHOD(show)
|
|||
RCT_EXPORT_METHOD(hide)
|
||||
{
|
||||
if (RCTRedBoxGetEnabled()) {
|
||||
__weak RCTLogBox *weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self->_view = nil;
|
||||
__strong RCTLogBox *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
strongSelf->_view = nil;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче