Skip to content

Commit f628679

Browse files
committed
FIX: Decrease figure refcount on close of a macosx figure
We need to take the refcount of the figuremanager down when we close a window. This was leaking figures before.
1 parent 161c96c commit f628679

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/_macosx.m

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ @interface Window : NSWindow
193193
- (Window*)initWithContentRect:(NSRect)rect styleMask:(unsigned int)mask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation withManager: (PyObject*)theManager;
194194
- (NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen*)screen;
195195
- (BOOL)closeButtonPressed;
196-
- (void)dealloc;
197196
@end
198197

199198
@interface View : NSView <NSWindowDelegate>
@@ -1239,19 +1238,9 @@ - (void)close
12391238
/* This is needed for show(), which should exit from [NSApp run]
12401239
* after all windows are closed.
12411240
*/
1242-
}
1243-
1244-
- (void)dealloc
1245-
{
1246-
PyGILState_STATE gstate;
1247-
gstate = PyGILState_Ensure();
1241+
// For each new window, we have incremented the manager reference, so
1242+
// we need to bring that down during close and not just dealloc.
12481243
Py_DECREF(manager);
1249-
PyGILState_Release(gstate);
1250-
/* The reference count of the view that was added as a subview to the
1251-
* content view of this window was increased during the call to addSubview,
1252-
* and is decreased during the call to [super dealloc].
1253-
*/
1254-
[super dealloc];
12551244
}
12561245
@end
12571246

0 commit comments

Comments
 (0)