Merge pull request #26625 from NekoAsakura:4.x

Cocoa/highgui: fix leak in cvGetWindowRect_COCOA
This commit is contained in:
Alexander Smorkalov 2024-12-20 09:03:33 +03:00 committed by GitHub
commit f3d9d56ebe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -662,14 +662,16 @@ CvRect cvGetWindowRect_COCOA( const char* name )
{ {
CV_ERROR( CV_StsNullPtr, "NULL window" ); CV_ERROR( CV_StsNullPtr, "NULL window" );
} else { } else {
NSRect rect = [window frame]; @autoreleasepool {
NSRect rect = [window frame];
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
NSPoint pt = [window convertRectToScreen:rect].origin; NSPoint pt = [window convertRectToScreen:rect].origin;
#else #else
NSPoint pt = [window convertBaseToScreen:rect.origin]; NSPoint pt = [window convertBaseToScreen:rect.origin];
#endif #endif
NSSize sz = [[[window contentView] image] size]; NSSize sz = [[[window contentView] image] size];
result = cvRect(pt.x, pt.y, sz.width, sz.height); result = cvRect(pt.x, pt.y, sz.width, sz.height);
}
} }
__END__; __END__;