diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index a3904603b2..d70f34d76a 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -1848,7 +1848,9 @@ static NSInteger incrementIfFound(NSInteger i) { } // now that we have a supernode, propagate its traits to self. - ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]); + if (newSupernode != nil) { + ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]); + } } } diff --git a/AsyncDisplayKit/Details/ASEnvironment.h b/AsyncDisplayKit/Details/ASEnvironment.h index 486f9f8852..4dad9fde9f 100644 --- a/AsyncDisplayKit/Details/ASEnvironment.h +++ b/AsyncDisplayKit/Details/ASEnvironment.h @@ -50,6 +50,7 @@ typedef struct ASEnvironmentLayoutOptionsState { struct ASEnvironmentStateExtensions _extensions; } ASEnvironmentLayoutOptionsState; +extern ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault(); #pragma mark - ASEnvironmentHierarchyState @@ -60,6 +61,7 @@ typedef struct ASEnvironmentHierarchyState { unsigned transitioningSupernodes:1; // = NO unsigned layoutPending:1; // = NO } ASEnvironmentHierarchyState; +extern ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault(); #pragma mark - ASEnvironmentDisplayTraits @@ -72,6 +74,7 @@ typedef struct ASEnvironmentTraitCollection { CGSize containerSize; } ASEnvironmentTraitCollection; +extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault(); extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionFromUITraitCollection(UITraitCollection *traitCollection); extern BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnvironmentTraitCollection lhs, ASEnvironmentTraitCollection rhs); diff --git a/AsyncDisplayKit/Details/ASEnvironment.mm b/AsyncDisplayKit/Details/ASEnvironment.mm index b0413de302..68aca910da 100644 --- a/AsyncDisplayKit/Details/ASEnvironment.mm +++ b/AsyncDisplayKit/Details/ASEnvironment.mm @@ -11,24 +11,25 @@ #import "ASEnvironmentInternal.h" #import "ASAvailability.h" -ASEnvironmentLayoutOptionsState _ASEnvironmentLayoutOptionsStateMakeDefault() +ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault() { return (ASEnvironmentLayoutOptionsState) { // Default values can be defined in here }; } -ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault() +ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault() { return (ASEnvironmentHierarchyState) { // Default values can be defined in here }; } -ASEnvironmentTraitCollection _ASEnvironmentTraitCollectionMakeDefault() +ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault() { return (ASEnvironmentTraitCollection) { // Default values can be defined in here + .userInterfaceIdiom = UIUserInterfaceIdiomUnspecified, .containerSize = CGSizeZero, }; } @@ -62,9 +63,9 @@ BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnviron ASEnvironmentState ASEnvironmentStateMakeDefault() { return (ASEnvironmentState) { - .layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(), - .hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(), - .environmentTraitCollection = _ASEnvironmentTraitCollectionMakeDefault() + .layoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault(), + .hierarchyState = ASEnvironmentHierarchyStateMakeDefault(), + .environmentTraitCollection = ASEnvironmentTraitCollectionMakeDefault() }; } diff --git a/AsyncDisplayKit/Private/ASEnvironmentInternal.h b/AsyncDisplayKit/Private/ASEnvironmentInternal.h index 0f1bcf1919..7179830eef 100644 --- a/AsyncDisplayKit/Private/ASEnvironmentInternal.h +++ b/AsyncDisplayKit/Private/ASEnvironmentInternal.h @@ -43,13 +43,13 @@ enum class ASEnvironmentStatePropagation { DOWN, UP }; static const struct ASEnvironmentStateExtensions ASEnvironmentDefaultStateExtensions = {}; -static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = {}; +static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault(); ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentLayoutOptionsState state, ASEnvironmentStatePropagation propagation); -static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = {}; +static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = ASEnvironmentHierarchyStateMakeDefault(); ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentHierarchyState state, ASEnvironmentStatePropagation propagation); -static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = {}; +static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = ASEnvironmentTraitCollectionMakeDefault(); ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentTraitCollection state, ASEnvironmentStatePropagation propagation);