cappuccino/cappuccino — Issue #1473: CPPopover memory leak
Author: danieljuanda
Created: 2012-03-07 21:40:15+00:00
State: open

In showRelativeToRect:ofView:positioningView:prefrerredEdge: _needsCompute is always YES, means it always creates a window. Windows will be put inside the applications windows array and will not be garbage collected when the popover is cleaned.

00200 - (void)showRelativeToRect:(CPRect)positioningRect ofView:(CPView)positioningView preferredEdge:(CPRectEdge)preferredEdge
00201 {
00202 if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
00203 [_delegate popoverWillShow:self];
00204
00205 if (!_contentViewController)
00206 [CPException raise:CPInternalInconsistencyException reason:@"contentViewController must not be nil"];
00207
00208 if (_needsCompute || !_attachedWindow)
00209 {
00210 var styleMask = (_behavior == CPPopoverBehaviorTransient) ? CPClosableOnBlurWindowMask : nil;
00211 _attachedWindow = [[_CPAttachedWindow alloc] initWithContentRect:CPRectMakeZero() styleMask:styleMask];
00212 }
00213
00214 [_attachedWindow setAppearance:_appearance];
00215 [_attachedWindow setAnimates:_animates];
00216 [_attachedWindow setDelegate:self];
00217 [_attachedWindow setMovableByWindowBackground:NO];
00218 [_attachedWindow setFrame:[_attachedWindow frameRectForContentRect:[[_contentViewController view] frame]]];
00219 [_attachedWindow setContentView:[_contentViewController view]];
00220
00221 if (positioningRect)
00222 [_attachedWindow positionRelativeToRect:positioningRect preferredEdge:preferredEdge];
00223 else if (positioningView)
00224 [_attachedWindow positionRelativeToView:positioningView preferredEdge:preferredEdge];
00225 else
00226 [CPException raise:CPInvalidArgumentException reason:@"a value must be passed for positioningRect or positioningView"];
00227
00228 if (_implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
00229 [_delegate popoverDidShow:self];
00230 }