Cocoa/highgui: fix leak in cvGetWindowRect_COCOA

This commit is contained in:
Neko Asakura 2024-12-14 04:34:43 +10:00
parent 1d4110884b
commit dbb330d7be

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__;