Skip to content

Commit f3d9d56

Browse files
authored
Merge pull request opencv#26625 from NekoAsakura:4.x
Cocoa/highgui: fix leak in cvGetWindowRect_COCOA
2 parents 8ffc4a6 + dbb330d commit f3d9d56

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

modules/highgui/src/window_cocoa.mm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,16 @@ CvRect cvGetWindowRect_COCOA( const char* name )
662662
{
663663
CV_ERROR( CV_StsNullPtr, "NULL window" );
664664
} else {
665-
NSRect rect = [window frame];
665+
@autoreleasepool {
666+
NSRect rect = [window frame];
666667
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
667-
NSPoint pt = [window convertRectToScreen:rect].origin;
668+
NSPoint pt = [window convertRectToScreen:rect].origin;
668669
#else
669-
NSPoint pt = [window convertBaseToScreen:rect.origin];
670+
NSPoint pt = [window convertBaseToScreen:rect.origin];
670671
#endif
671-
NSSize sz = [[[window contentView] image] size];
672-
result = cvRect(pt.x, pt.y, sz.width, sz.height);
672+
NSSize sz = [[[window contentView] image] size];
673+
result = cvRect(pt.x, pt.y, sz.width, sz.height);
674+
}
673675
}
674676

675677
__END__;

0 commit comments

Comments
 (0)