@@ -138,7 +138,6 @@ static int wait_for_stdin(void)
138138 }
139139
140140 NSEvent * event;
141- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
142141 while (true ) {
143142 while (true ) {
144143 event = [NSApp nextEventMatchingMask: NSAnyEventMask
@@ -151,7 +150,6 @@ static int wait_for_stdin(void)
151150 CFRunLoopRun ();
152151 if (interrupted || CFReadStreamHasBytesAvailable (stream)) break ;
153152 }
154- [pool release ];
155153
156154 if (py_sigint_handler) PyOS_setsig (SIGINT, py_sigint_handler);
157155 CFReadStreamUnscheduleFromRunLoop (stream,
@@ -280,15 +278,13 @@ static void lazy_init(void) {
280278 PyOS_InputHook = wait_for_stdin;
281279#endif
282280
283- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
284281 WindowServerConnectionManager* connectionManager = [WindowServerConnectionManager sharedManager ];
285282 NSWorkspace * workspace = [NSWorkspace sharedWorkspace ];
286283 NSNotificationCenter * notificationCenter = [workspace notificationCenter ];
287284 [notificationCenter addObserver: connectionManager
288285 selector: @selector (launch: )
289286 name: NSWorkspaceDidLaunchApplicationNotification
290287 object: nil ];
291- [pool release ];
292288}
293289
294290static PyObject*
@@ -366,11 +362,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
366362
367363 if (view) /* The figure may have been closed already */
368364 {
369- /* Whereas drawRect creates its own autorelease pool, apparently
370- * [view display] also needs one. Create and release it here. */
371- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
372365 [view display ];
373- [pool release ];
374366 }
375367
376368 Py_RETURN_NONE;
@@ -506,7 +498,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
506498 close (channel[0 ]);
507499 }
508500
509- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
510501 NSDate * date =
511502 (timeout > 0.0 ) ? [NSDate dateWithTimeIntervalSinceNow: timeout]
512503 : [NSDate distantFuture ];
@@ -518,7 +509,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
518509 if (!event || [event type ]==NSApplicationDefined ) break ;
519510 [NSApp sendEvent: event];
520511 }
521- [pool release ];
522512
523513 if (py_sigint_handler) PyOS_setsig (SIGINT, py_sigint_handler);
524514
@@ -691,7 +681,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
691681 rect.size .height = height;
692682 rect.size .width = width;
693683
694- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
695684 self->window = [self ->window initWithContentRect: rect
696685 styleMask: NSTitledWindowMask
697686 | NSClosableWindowMask
@@ -709,7 +698,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
709698 [window makeFirstResponder: view];
710699 [[window contentView ] addSubview: view];
711700
712- [pool release ];
713701 return 0 ;
714702}
715703
@@ -726,9 +714,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
726714 Window* window = self->window ;
727715 if (window)
728716 {
729- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
730717 [window close ];
731- [pool release ];
732718 }
733719 Py_TYPE (self)->tp_free ((PyObject*)self);
734720}
@@ -739,10 +725,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
739725 Window* window = self->window ;
740726 if (window)
741727 {
742- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
743728 [window makeKeyAndOrderFront: nil ];
744729 [window orderFrontRegardless ];
745- [pool release ];
746730 }
747731 Py_RETURN_NONE;
748732}
@@ -770,12 +754,10 @@ static CGFloat _get_device_scale(CGContextRef cr)
770754 Window* window = self->window ;
771755 if (window)
772756 {
773- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
774757 NSString * ns_title = [[[NSString alloc ]
775758 initWithCString: title
776759 encoding: NSUTF8StringEncoding] autorelease ];
777760 [window setTitle: ns_title];
778- [pool release ];
779761 }
780762 Py_RETURN_NONE;
781763}
@@ -787,13 +769,11 @@ static CGFloat _get_device_scale(CGContextRef cr)
787769 PyObject* result = NULL ;
788770 if (window)
789771 {
790- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
791772 NSString * title = [window title ];
792773 if (title) {
793774 const char * cTitle = [title UTF8String ];
794775 result = PyUnicode_FromString (cTitle);
795776 }
796- [pool release ];
797777 }
798778 if (result) {
799779 return result;
@@ -1098,9 +1078,9 @@ -(void)save_figure:(id)sender
10981078 const float gap = 2 ;
10991079 const int height = 36 ;
11001080 const int imagesize = 24 ;
1101-
1081+
11021082 self->height = height;
1103-
1083+
11041084 const char * basedir;
11051085
11061086 obj = PyObject_GetAttrString ((PyObject*)self, " canvas" );
@@ -1125,7 +1105,6 @@ -(void)save_figure:(id)sender
11251105
11261106 if (!PyArg_ParseTuple (args, " s" , &basedir)) return -1 ;
11271107
1128- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
11291108 NSRect bounds = [view bounds ];
11301109 NSWindow * window = [view window ];
11311110
@@ -1228,8 +1207,6 @@ -(void)save_figure:(id)sender
12281207 [messagebox release ];
12291208 [[window contentView ] display ];
12301209
1231- [pool release ];
1232-
12331210 self->messagebox = messagebox;
12341211 return 0 ;
12351212}
@@ -1260,24 +1237,22 @@ -(void)save_figure:(id)sender
12601237 NSTextView * messagebox = self->messagebox ;
12611238
12621239 if (messagebox)
1263- { NSAutoreleasePool * pool = [[ NSAutoreleasePool alloc ] init ];
1240+ {
12641241 NSString * text = [NSString stringWithUTF8String: message];
12651242 [messagebox setString: text];
1266-
1243+
12671244 // Adjust width with the window size
12681245 NSRect rectWindow = [messagebox.superview frame ];
12691246 NSRect rect = [messagebox frame ];
12701247 rect.size .width = rectWindow.size .width - rect.origin .x ;
12711248 [messagebox setFrame: rect];
1272-
1249+
12731250 // Adjust height with the content size
12741251 [messagebox.layoutManager ensureLayoutForTextContainer: messagebox.textContainer];
12751252 NSRect contentSize = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
12761253 rect = [messagebox frame ];
12771254 rect.origin .y = 0.5 * (self->height - contentSize.size .height );
12781255 [messagebox setFrame: rect];
1279-
1280- [pool release ];
12811256 }
12821257
12831258 Py_RETURN_NONE;
@@ -2315,14 +2290,12 @@ - (int)index
23152290show (PyObject* self)
23162291{
23172292 [NSApp activateIgnoringOtherApps: YES ];
2318- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
23192293 NSArray *windowsArray = [NSApp windows ];
23202294 NSEnumerator *enumerator = [windowsArray objectEnumerator ];
23212295 NSWindow *window;
23222296 while ((window = [enumerator nextObject ])) {
23232297 [window orderFront: nil ];
23242298 }
2325- [pool release ];
23262299 Py_BEGIN_ALLOW_THREADS
23272300 [NSApp run ];
23282301 Py_END_ALLOW_THREADS
0 commit comments