Dont use a global autorelease variable
Use function local @autorelease blocks instead
This commit is contained in:
@@ -324,7 +324,7 @@ is_cmd_period(NSEvent *event, NSEventModifierFlags modifierFlags) {
|
|||||||
|
|
||||||
int _glfwPlatformInit(void)
|
int _glfwPlatformInit(void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
@autoreleasepool {
|
||||||
_glfw.ns.helper = [[GLFWHelper alloc] init];
|
_glfw.ns.helper = [[GLFWHelper alloc] init];
|
||||||
|
|
||||||
[NSThread detachNewThreadSelector:@selector(doNothing:)
|
[NSThread detachNewThreadSelector:@selector(doNothing:)
|
||||||
@@ -392,13 +392,14 @@ int _glfwPlatformInit(void)
|
|||||||
_glfwInitJoysticksNS();
|
_glfwInitJoysticksNS();
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
_glfwPollMonitorsNS();
|
||||||
[pool drain];
|
}
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwPlatformTerminate(void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
@autoreleasepool {
|
||||||
|
|
||||||
if (_glfw.ns.displayLinks.lock) {
|
if (_glfw.ns.displayLinks.lock) {
|
||||||
_glfwClearDisplayLinks();
|
_glfwClearDisplayLinks();
|
||||||
[_glfw.ns.displayLinks.lock release];
|
[_glfw.ns.displayLinks.lock release];
|
||||||
@@ -445,7 +446,7 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
_glfwTerminateNSGL();
|
_glfwTerminateNSGL();
|
||||||
_glfwTerminateJoysticksNS();
|
_glfwTerminateJoysticksNS();
|
||||||
[pool drain];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
|
|||||||
@@ -1805,7 +1805,7 @@ requestRenderFrame(_GLFWwindow *w, GLFWcocoarenderframefun callback) {
|
|||||||
|
|
||||||
void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start)
|
void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
@autoreleasepool {
|
||||||
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
|
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
|
||||||
location:NSMakePoint(0, 0)
|
location:NSMakePoint(0, 0)
|
||||||
modifierFlags:0
|
modifierFlags:0
|
||||||
@@ -1816,7 +1816,7 @@ void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start)
|
|||||||
data1:data1
|
data1:data1
|
||||||
data2:0];
|
data2:0];
|
||||||
[NSApp postEvent:event atStart:at_start ? YES : NO];
|
[NSApp postEvent:event atStart:at_start ? YES : NO];
|
||||||
[pool drain];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPostEmptyEvent(void)
|
void _glfwPlatformPostEmptyEvent(void)
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ cocoa_send_notification(PyObject *self UNUSED, PyObject *args) {
|
|||||||
// global menu {{{
|
// global menu {{{
|
||||||
void
|
void
|
||||||
cocoa_create_global_menu(void) {
|
cocoa_create_global_menu(void) {
|
||||||
|
@autoreleasepool {
|
||||||
NSString* app_name = find_app_name();
|
NSString* app_name = find_app_name();
|
||||||
NSMenu* bar = [[NSMenu alloc] init];
|
NSMenu* bar = [[NSMenu alloc] init];
|
||||||
GlobalMenuTarget *global_menu_target = [GlobalMenuTarget shared_instance];
|
GlobalMenuTarget *global_menu_target = [GlobalMenuTarget shared_instance];
|
||||||
@@ -323,6 +324,7 @@ cocoa_create_global_menu(void) {
|
|||||||
|
|
||||||
|
|
||||||
[NSApp setServicesProvider:[[[ServiceProvider alloc] init] autorelease]];
|
[NSApp setServicesProvider:[[[ServiceProvider alloc] init] autorelease]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -415,6 +417,7 @@ cocoa_toggle_fullscreen(void *w, bool traditional) {
|
|||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
cocoa_get_lang(PyObject UNUSED *self) {
|
cocoa_get_lang(PyObject UNUSED *self) {
|
||||||
|
@autoreleasepool {
|
||||||
NSString* locale = nil;
|
NSString* locale = nil;
|
||||||
NSString* lang_code = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];
|
NSString* lang_code = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];
|
||||||
NSString* country_code = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
|
NSString* country_code = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
|
||||||
@@ -425,10 +428,12 @@ cocoa_get_lang(PyObject UNUSED *self) {
|
|||||||
}
|
}
|
||||||
if (!locale) { Py_RETURN_NONE; }
|
if (!locale) { Py_RETURN_NONE; }
|
||||||
return Py_BuildValue("s", [locale UTF8String]);
|
return Py_BuildValue("s", [locale UTF8String]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
cocoa_cursor_blink_interval(void) {
|
cocoa_cursor_blink_interval(void) {
|
||||||
|
@autoreleasepool {
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
double on_period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriodOn"];
|
double on_period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriodOn"];
|
||||||
double off_period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriodOff"];
|
double off_period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriodOff"];
|
||||||
@@ -440,6 +445,7 @@ cocoa_cursor_blink_interval(void) {
|
|||||||
ans = period_ms;
|
ans = period_ms;
|
||||||
}
|
}
|
||||||
return ans > max_value ? 0.0 : ans;
|
return ans > max_value ? 0.0 : ans;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -450,6 +456,7 @@ cocoa_set_hide_from_tasks(void) {
|
|||||||
void
|
void
|
||||||
cocoa_set_titlebar_color(void *w, color_type titlebar_color)
|
cocoa_set_titlebar_color(void *w, color_type titlebar_color)
|
||||||
{
|
{
|
||||||
|
@autoreleasepool {
|
||||||
NSWindow *window = (NSWindow *)w;
|
NSWindow *window = (NSWindow *)w;
|
||||||
|
|
||||||
double red = ((titlebar_color >> 16) & 0xFF) / 255.0;
|
double red = ((titlebar_color >> 16) & 0xFF) / 255.0;
|
||||||
@@ -471,14 +478,17 @@ cocoa_set_titlebar_color(void *w, color_type titlebar_color)
|
|||||||
} else {
|
} else {
|
||||||
[window setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
|
[window setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
@autoreleasepool {
|
||||||
if (dockMenu) [dockMenu release];
|
if (dockMenu) [dockMenu release];
|
||||||
dockMenu = nil;
|
dockMenu = nil;
|
||||||
if (notification_activated_callback) Py_DECREF(notification_activated_callback);
|
if (notification_activated_callback) Py_DECREF(notification_activated_callback);
|
||||||
notification_activated_callback = NULL;
|
notification_activated_callback = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef module_methods[] = {
|
static PyMethodDef module_methods[] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user