Fix leak of display mode

This commit is contained in:
DreamPiggy 2023-02-18 18:07:07 +08:00
parent 3440b7c0fb
commit 856ecd6235
2 changed files with 9 additions and 4 deletions

View File

@ -26,7 +26,7 @@ static void * SDWebImageDownloaderOperationKey = &SDWebImageDownloaderOperationK
BOOL SDWebImageDownloaderOperationGetCompleted(id<SDWebImageDownloaderOperation> operation) {
NSCParameterAssert(operation);
NSNumber *value = objc_getAssociatedObject(operation, SDWebImageDownloaderOperationKey);
if (value) {
if (value != nil) {
return value.boolValue;
} else {
return NO;

View File

@ -116,9 +116,14 @@ static CFTimeInterval CACurrentMediaTime(void)
// Supports Pro display 120Hz
CGDirectDisplayID display = CVDisplayLinkGetCurrentCGDisplay(_displayLink);
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(display);
double refreshRate = CGDisplayModeGetRefreshRate(mode);
if (refreshRate > 0) {
duration = 1.0 / refreshRate;
if (mode) {
double refreshRate = CGDisplayModeGetRefreshRate(mode);
if (refreshRate > 0) {
duration = 1.0 / refreshRate;
} else {
duration = kSDDisplayLinkInterval;
}
CGDisplayModeRelease(mode);
} else {
duration = kSDDisplayLinkInterval;
}