@@ -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,
@@ -280,15 +278,13 @@ static void lazy_init(void) {
280
278
PyOS_InputHook = wait_for_stdin;
281
279
#endif
282
280
283
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
284
281
WindowServerConnectionManager* connectionManager = [WindowServerConnectionManager sharedManager ];
285
282
NSWorkspace * workspace = [NSWorkspace sharedWorkspace ];
286
283
NSNotificationCenter * notificationCenter = [workspace notificationCenter ];
287
284
[notificationCenter addObserver: connectionManager
288
285
selector: @selector (launch: )
289
286
name: NSWorkspaceDidLaunchApplicationNotification
290
287
object: nil ];
291
- [pool release ];
292
288
}
293
289
294
290
static PyObject*
@@ -366,11 +362,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
366
362
367
363
if (view) /* The figure may have been closed already */
368
364
{
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 ];
372
365
[view display ];
373
- [pool release ];
374
366
}
375
367
376
368
Py_RETURN_NONE;
@@ -506,7 +498,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
506
498
close (channel[0 ]);
507
499
}
508
500
509
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
510
501
NSDate * date =
511
502
(timeout > 0.0 ) ? [NSDate dateWithTimeIntervalSinceNow: timeout]
512
503
: [NSDate distantFuture ];
@@ -518,7 +509,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
518
509
if (!event || [event type ]==NSApplicationDefined ) break ;
519
510
[NSApp sendEvent: event];
520
511
}
521
- [pool release ];
522
512
523
513
if (py_sigint_handler) PyOS_setsig (SIGINT, py_sigint_handler);
524
514
@@ -691,7 +681,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
691
681
rect.size .height = height;
692
682
rect.size .width = width;
693
683
694
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
695
684
self->window = [self ->window initWithContentRect: rect
696
685
styleMask: NSTitledWindowMask
697
686
| NSClosableWindowMask
@@ -709,7 +698,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
709
698
[window makeFirstResponder: view];
710
699
[[window contentView ] addSubview: view];
711
700
712
- [pool release ];
713
701
return 0 ;
714
702
}
715
703
@@ -726,9 +714,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
726
714
Window* window = self->window ;
727
715
if (window)
728
716
{
729
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
730
717
[window close ];
731
- [pool release ];
732
718
}
733
719
Py_TYPE (self)->tp_free ((PyObject*)self);
734
720
}
@@ -739,10 +725,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
739
725
Window* window = self->window ;
740
726
if (window)
741
727
{
742
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
743
728
[window makeKeyAndOrderFront: nil ];
744
729
[window orderFrontRegardless ];
745
- [pool release ];
746
730
}
747
731
Py_RETURN_NONE;
748
732
}
@@ -770,12 +754,10 @@ static CGFloat _get_device_scale(CGContextRef cr)
770
754
Window* window = self->window ;
771
755
if (window)
772
756
{
773
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
774
757
NSString * ns_title = [[[NSString alloc ]
775
758
initWithCString: title
776
759
encoding: NSUTF8StringEncoding] autorelease ];
777
760
[window setTitle: ns_title];
778
- [pool release ];
779
761
}
780
762
Py_RETURN_NONE;
781
763
}
@@ -787,13 +769,11 @@ static CGFloat _get_device_scale(CGContextRef cr)
787
769
PyObject* result = NULL ;
788
770
if (window)
789
771
{
790
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
791
772
NSString * title = [window title ];
792
773
if (title) {
793
774
const char * cTitle = [title UTF8String ];
794
775
result = PyUnicode_FromString (cTitle);
795
776
}
796
- [pool release ];
797
777
}
798
778
if (result) {
799
779
return result;
@@ -1098,9 +1078,9 @@ -(void)save_figure:(id)sender
1098
1078
const float gap = 2 ;
1099
1079
const int height = 36 ;
1100
1080
const int imagesize = 24 ;
1101
-
1081
+
1102
1082
self->height = height;
1103
-
1083
+
1104
1084
const char * basedir;
1105
1085
1106
1086
obj = PyObject_GetAttrString ((PyObject*)self, " canvas" );
@@ -1125,7 +1105,6 @@ -(void)save_figure:(id)sender
1125
1105
1126
1106
if (!PyArg_ParseTuple (args, " s" , &basedir)) return -1 ;
1127
1107
1128
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
1129
1108
NSRect bounds = [view bounds ];
1130
1109
NSWindow * window = [view window ];
1131
1110
@@ -1228,8 +1207,6 @@ -(void)save_figure:(id)sender
1228
1207
[messagebox release ];
1229
1208
[[window contentView ] display ];
1230
1209
1231
- [pool release ];
1232
-
1233
1210
self->messagebox = messagebox;
1234
1211
return 0 ;
1235
1212
}
@@ -1260,24 +1237,22 @@ -(void)save_figure:(id)sender
1260
1237
NSTextView * messagebox = self->messagebox ;
1261
1238
1262
1239
if (messagebox)
1263
- { NSAutoreleasePool * pool = [[ NSAutoreleasePool alloc ] init ];
1240
+ {
1264
1241
NSString * text = [NSString stringWithUTF8String: message];
1265
1242
[messagebox setString: text];
1266
-
1243
+
1267
1244
// Adjust width with the window size
1268
1245
NSRect rectWindow = [messagebox.superview frame ];
1269
1246
NSRect rect = [messagebox frame ];
1270
1247
rect.size .width = rectWindow.size .width - rect.origin .x ;
1271
1248
[messagebox setFrame: rect];
1272
-
1249
+
1273
1250
// Adjust height with the content size
1274
1251
[messagebox.layoutManager ensureLayoutForTextContainer: messagebox.textContainer];
1275
1252
NSRect contentSize = [messagebox.layoutManager usedRectForTextContainer: messagebox.textContainer];
1276
1253
rect = [messagebox frame ];
1277
1254
rect.origin .y = 0.5 * (self->height - contentSize.size .height );
1278
1255
[messagebox setFrame: rect];
1279
-
1280
- [pool release ];
1281
1256
}
1282
1257
1283
1258
Py_RETURN_NONE;
@@ -2315,14 +2290,12 @@ - (int)index
2315
2290
show (PyObject* self)
2316
2291
{
2317
2292
[NSApp activateIgnoringOtherApps: YES ];
2318
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
2319
2293
NSArray *windowsArray = [NSApp windows ];
2320
2294
NSEnumerator *enumerator = [windowsArray objectEnumerator ];
2321
2295
NSWindow *window;
2322
2296
while ((window = [enumerator nextObject ])) {
2323
2297
[window orderFront: nil ];
2324
2298
}
2325
- [pool release ];
2326
2299
Py_BEGIN_ALLOW_THREADS
2327
2300
[NSApp run ];
2328
2301
Py_END_ALLOW_THREADS
0 commit comments