mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
nil out displayContext when we get a new one
Summary: Don't set the new one in the subnodes yet as this will cause ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection to return NO if only the displayContext changed. Reviewers: garrett, levi, rmalik Reviewed By: garrett, levi, rmalik Subscribers: rmalik Differential Revision: https://phabricator.pinadmin.com/D94320
This commit is contained in:
@@ -33,7 +33,7 @@ typedef ASTraitCollection * _Nonnull (^ASDisplayTraitsForTraitWindowSizeBlock)(C
|
|||||||
* ASVC keeps a strong reference to the context to make sure that it stays alive. If you change this value
|
* ASVC keeps a strong reference to the context to make sure that it stays alive. If you change this value
|
||||||
* it will propagate the change to the subnodes.
|
* it will propagate the change to the subnodes.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) id _Nullable traitColectionContext;
|
@property (nonatomic, strong) id _Nullable traitCollectionContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this block to customize the ASDisplayTraits returned when the VC transitions to the given traitCollection.
|
* Set this block to customize the ASDisplayTraits returned when the VC transitions to the given traitCollection.
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
if (_traitColectionContext != nil) {
|
if (_traitCollectionContext != nil) {
|
||||||
// The setter will iterate through the VC's subnodes and replace the traitCollectionContext in their ASEnvironmentTraitCollection with nil.
|
// The setter will iterate through the VC's subnodes and replace the traitCollectionContext in their ASEnvironmentTraitCollection with nil.
|
||||||
// Since the VC holds the only strong reference to this context and we are in the process of destroying
|
// Since the VC holds the only strong reference to this context and we are in the process of destroying
|
||||||
// the VC, all the references in the subnodes will be unsafe unless we nil them out. More than likely all the subnodes will be dealloc'ed
|
// the VC, all the references in the subnodes will be unsafe unless we nil them out. More than likely all the subnodes will be dealloc'ed
|
||||||
@@ -195,13 +195,14 @@ ASVisibilityDepthImplementation;
|
|||||||
|
|
||||||
#pragma mark - ASEnvironmentTraitCollection
|
#pragma mark - ASEnvironmentTraitCollection
|
||||||
|
|
||||||
- (void)setTraitColectionContext:(id)traitColectionContext
|
- (void)setTraitColectionContext:(id)traitCollectionContext
|
||||||
{
|
{
|
||||||
if (_traitColectionContext != traitColectionContext) {
|
if (_traitCollectionContext != traitCollectionContext) {
|
||||||
// propagate first so that nodes aren't hanging around with a dealloc'ed pointer
|
// nil out the displayContext in the subnodes so they aren't hanging around with a dealloc'ed pointer don't set
|
||||||
ASEnvironmentTraitCollectionUpdateDisplayContext(self.node, traitColectionContext);
|
// the new context yet as this will cause ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection to fail
|
||||||
|
ASEnvironmentTraitCollectionUpdateDisplayContext(self.node, nil);
|
||||||
|
|
||||||
_traitColectionContext = traitColectionContext;
|
_traitCollectionContext = traitCollectionContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ ASVisibilityDepthImplementation;
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASEnvironmentTraitCollection asyncTraitCollection = ASEnvironmentTraitCollectionFromUITraitCollection(traitCollection);
|
ASEnvironmentTraitCollection asyncTraitCollection = ASEnvironmentTraitCollectionFromUITraitCollection(traitCollection);
|
||||||
asyncTraitCollection.displayContext = self.traitColectionContext;
|
asyncTraitCollection.displayContext = self.traitCollectionContext;
|
||||||
return asyncTraitCollection;
|
return asyncTraitCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user