@@ -138,7 +138,6 @@ static int wait_for_stdin(void)
138
138
}
139
139
140
140
NSEvent * event;
141
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
142
141
while (true ) {
143
142
while (true ) {
144
143
event = [NSApp nextEventMatchingMask: NSAnyEventMask
@@ -151,7 +150,6 @@ static int wait_for_stdin(void)
151
150
CFRunLoopRun ();
152
151
if (interrupted || CFReadStreamHasBytesAvailable (stream)) break ;
153
152
}
154
- [pool release ];
155
153
156
154
if (py_sigint_handler) PyOS_setsig (SIGINT, py_sigint_handler);
157
155
CFReadStreamUnscheduleFromRunLoop (stream,
@@ -279,15 +277,13 @@ static void lazy_init(void) {
279
277
PyOS_InputHook = wait_for_stdin;
280
278
#endif
281
279
282
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
283
280
WindowServerConnectionManager* connectionManager = [WindowServerConnectionManager sharedManager ];
284
281
NSWorkspace * workspace = [NSWorkspace sharedWorkspace ];
285
282
NSNotificationCenter * notificationCenter = [workspace notificationCenter ];
286
283
[notificationCenter addObserver: connectionManager
287
284
selector: @selector (launch: )
288
285
name: NSWorkspaceDidLaunchApplicationNotification
289
286
object: nil ];
290
- [pool release ];
291
287
}
292
288
293
289
static PyObject*
@@ -373,11 +369,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
373
369
374
370
if (view) /* The figure may have been closed already */
375
371
{
376
- /* Whereas drawRect creates its own autorelease pool, apparently
377
- * [view display] also needs one. Create and release it here. */
378
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
379
372
[view display ];
380
- [pool release ];
381
373
}
382
374
383
375
Py_RETURN_NONE;
@@ -513,7 +505,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
513
505
close (channel[0 ]);
514
506
}
515
507
516
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
517
508
NSDate * date =
518
509
(timeout > 0.0 ) ? [NSDate dateWithTimeIntervalSinceNow: timeout]
519
510
: [NSDate distantFuture ];
@@ -525,7 +516,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
525
516
if (!event || [event type ]==NSApplicationDefined ) break ;
526
517
[NSApp sendEvent: event];
527
518
}
528
- [pool release ];
529
519
530
520
if (py_sigint_handler) PyOS_setsig (SIGINT, py_sigint_handler);
531
521
@@ -698,7 +688,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
698
688
rect.size .height = height;
699
689
rect.size .width = width;
700
690
701
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
702
691
self->window = [self ->window initWithContentRect: rect
703
692
styleMask: NSTitledWindowMask
704
693
| NSClosableWindowMask
@@ -715,7 +704,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
715
704
[window makeFirstResponder: view];
716
705
[[window contentView ] addSubview: view];
717
706
718
- [pool release ];
719
707
return 0 ;
720
708
}
721
709
@@ -732,9 +720,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
732
720
Window* window = self->window ;
733
721
if (window)
734
722
{
735
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
736
723
[window close ];
737
- [pool release ];
738
724
}
739
725
Py_TYPE (self)->tp_free ((PyObject*)self);
740
726
}
@@ -745,10 +731,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
745
731
Window* window = self->window ;
746
732
if (window)
747
733
{
748
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
749
734
[window makeKeyAndOrderFront: nil ];
750
735
[window orderFrontRegardless ];
751
- [pool release ];
752
736
}
753
737
Py_RETURN_NONE;
754
738
}
@@ -759,9 +743,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
759
743
Window* window = self->window ;
760
744
if (window)
761
745
{
762
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
763
746
[window close ];
764
- [pool release ];
765
747
self->window = NULL ;
766
748
}
767
749
Py_RETURN_NONE;
@@ -778,12 +760,10 @@ static CGFloat _get_device_scale(CGContextRef cr)
778
760
Window* window = self->window ;
779
761
if (window)
780
762
{
781
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
782
763
NSString * ns_title = [[[NSString alloc ]
783
764
initWithCString: title
784
765
encoding: NSUTF8StringEncoding] autorelease ];
785
766
[window setTitle: ns_title];
786
- [pool release ];
787
767
}
788
768
Py_RETURN_NONE;
789
769
}
@@ -795,13 +775,11 @@ static CGFloat _get_device_scale(CGContextRef cr)
795
775
PyObject* result = NULL ;
796
776
if (window)
797
777
{
798
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
799
778
NSString * title = [window title ];
800
779
if (title) {
801
780
const char * cTitle = [title UTF8String ];
802
781
result = PyUnicode_FromString (cTitle);
803
782
}
804
- [pool release ];
805
783
}
806
784
if (result) {
807
785
return result;
@@ -1127,9 +1105,9 @@ -(void)save_figure:(id)sender
1127
1105
const float gap = 2 ;
1128
1106
const int height = 36 ;
1129
1107
const int imagesize = 24 ;
1130
-
1108
+
1131
1109
self->height = height;
1132
-
1110
+
1133
1111
const char * basedir;
1134
1112
1135
1113
obj = PyObject_GetAttrString ((PyObject*)self, " canvas" );
@@ -1154,7 +1132,6 @@ -(void)save_figure:(id)sender
1154
1132
1155
1133
if (!PyArg_ParseTuple (args, " s" , &basedir)) return -1 ;
1156
1134
1157
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
1158
1135
NSRect bounds = [view bounds ];
1159
1136
NSWindow * window = [view window ];
1160
1137
@@ -1257,8 +1234,6 @@ -(void)save_figure:(id)sender
1257
1234
[messagebox release ];
1258
1235
[[window contentView ] display ];
1259
1236
1260
- [pool release ];
1261
-
1262
1237
self->messagebox = messagebox;
1263
1238
return 0 ;
1264
1239
}
@@ -1289,24 +1264,22 @@ -(void)save_figure:(id)sender
1289
1264
NSTextView * messagebox = self->messagebox ;
1290
1265
1291
1266
if (messagebox)
1292
- { NSAutoreleasePool * pool = [[ NSAutoreleasePool alloc ] init ];
1267
+ {
1293
1268
NSString * text = [NSString stringWithUTF8String: message];
1294
1269
[messagebox setString: text];
1295
-
1270
+
1296
1271
// Adjust width with the window size
1297
1272
NSRect rectWindow = [messagebox.superview frame ];
1298
1273
NSRect rect = [messagebox frame ];
1299
1274
rect.size .width = rectWindow.size .width - rect.origin .x ;
1300
1275
[messagebox setFrame: rect];
1301
-
1276
+
1302
1277
// Adjust height with the content size
1303
1278
[messagebox.layoutManager ensureLayoutForTextContainer: messagebox.textContainer];
1304
1279
NSRect contentSize = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
1305
1280
rect = [messagebox frame ];
1306
1281
rect.origin .y = 0.5 * (self->height - contentSize.size .height );
1307
1282
[messagebox setFrame: rect];
1308
-
1309
- [pool release ];
1310
1283
}
1311
1284
1312
1285
Py_RETURN_NONE;
@@ -2323,14 +2296,12 @@ - (int)index
2323
2296
show (PyObject* self)
2324
2297
{
2325
2298
[NSApp activateIgnoringOtherApps: YES ];
2326
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
2327
2299
NSArray *windowsArray = [NSApp windows ];
2328
2300
NSEnumerator *enumerator = [windowsArray objectEnumerator ];
2329
2301
NSWindow *window;
2330
2302
while ((window = [enumerator nextObject ])) {
2331
2303
[window orderFront: nil ];
2332
2304
}
2333
- [pool release ];
2334
2305
Py_BEGIN_ALLOW_THREADS
2335
2306
[NSApp run ];
2336
2307
Py_END_ALLOW_THREADS
0 commit comments