mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-20 13:19:16 +00:00
[ASImageNode] -setDefaultImage: should release lock before calling -setImage:
This allows -setImage: to fully unlock before it calls -invalidateCalculatedSize.
This commit is contained in:
parent
5f58b9d8af
commit
a966b7b6a6
@ -132,15 +132,22 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
||||
|
||||
- (void)setDefaultImage:(UIImage *)defaultImage
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
_lock.lock();
|
||||
|
||||
if (ASObjectIsEqual(defaultImage, _defaultImage)) {
|
||||
_lock.unlock();
|
||||
return;
|
||||
}
|
||||
_defaultImage = defaultImage;
|
||||
|
||||
if (!_imageLoaded) {
|
||||
self.image = _defaultImage;
|
||||
_lock.unlock();
|
||||
// Locking: it is important to release _lock before entering setImage:, as it needs to release the lock before -invalidateCalculatedLayout.
|
||||
// If we continue to hold the lock here, it will still be locked until the next unlock() call, causing a possible deadlock with
|
||||
// -[ASNetworkImageNode displayWillStart] (which is called on a different thread / main, at an unpredictable time due to ASMainRunloopQueue).
|
||||
self.image = defaultImage;
|
||||
} else {
|
||||
_lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user