Fixes a deadlock caused by walking up the heirarchy. (#2147)

* Fixes a deadlock caused by walking up the heirarchy.

* Use scope locker / unlocker and add a comment.

* Add comment about calling __setNeedsLayout without the lock.
This commit is contained in:
Garrett Moon
2016-08-26 14:09:38 -07:00
committed by Adlai Holler
parent e6e5c346de
commit 8032758176

View File

@@ -1182,6 +1182,9 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
// but automatic subnode management would require us to modify the node tree
// in the background on a loaded node, which isn't currently supported.
if (_pendingViewState.hasSetNeedsLayout) {
//Need to unlock before calling setNeedsLayout to avoid deadlocks.
//MutexUnlocker will re-lock at the end of scope.
ASDN::MutexUnlocker u(__instanceLock__);
[self __setNeedsLayout];
}
@@ -1213,6 +1216,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
[self displayImmediately];
}
//Calling this with the lock held can lead to deadlocks. Always call *unlocked*
- (void)__setNeedsLayout
{
ASDisplayNodeAssertThreadAffinity(self);