Commit c937e991 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

winemac.drv: Use @autoreleasepool instead of NSAutoreleasePool.

parent 3582ba9d
...@@ -333,14 +333,15 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -333,14 +333,15 @@ static NSString* WineLocalizedString(unsigned int stringID)
{ {
if (processEvents) if (processEvents)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny {
untilDate:timeout NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
inMode:NSDefaultRunLoopMode untilDate:timeout
dequeue:YES]; inMode:NSDefaultRunLoopMode
if (event) dequeue:YES];
[NSApp sendEvent:event]; if (event)
[pool release]; [NSApp sendEvent:event];
}
} }
else else
[[NSRunLoop currentRunLoop] runMode:WineAppWaitQueryResponseMode beforeDate:timeout]; [[NSRunLoop currentRunLoop] runMode:WineAppWaitQueryResponseMode beforeDate:timeout];
...@@ -2281,34 +2282,34 @@ static NSString* WineLocalizedString(unsigned int stringID) ...@@ -2281,34 +2282,34 @@ static NSString* WineLocalizedString(unsigned int stringID)
*/ */
static void PerformRequest(void *info) static void PerformRequest(void *info)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineApplicationController* controller = [WineApplicationController sharedController]; WineApplicationController* controller = [WineApplicationController sharedController];
for (;;) for (;;)
{ {
__block dispatch_block_t block; @autoreleasepool
{
dispatch_sync(controller->requestsManipQueue, ^{ __block dispatch_block_t block;
if ([controller->requests count])
{
block = (dispatch_block_t)[[controller->requests objectAtIndex:0] retain];
[controller->requests removeObjectAtIndex:0];
}
else
block = nil;
});
if (!block) dispatch_sync(controller->requestsManipQueue, ^{
break; if ([controller->requests count])
{
block = (dispatch_block_t)[[controller->requests objectAtIndex:0] retain];
[controller->requests removeObjectAtIndex:0];
}
else
block = nil;
});
block(); if (!block)
[block release]; break;
[pool release]; block();
pool = [[NSAutoreleasePool alloc] init]; [block release];
}
} }
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -2347,13 +2348,12 @@ void LogError(const char* func, NSString* format, ...) ...@@ -2347,13 +2348,12 @@ void LogError(const char* func, NSString* format, ...)
*/ */
void LogErrorv(const char* func, NSString* format, va_list args) void LogErrorv(const char* func, NSString* format, va_list args)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; NSString* message = [[NSString alloc] initWithFormat:format arguments:args];
fprintf(stderr, "err:%s:%s", func, [message UTF8String]); fprintf(stderr, "err:%s:%s", func, [message UTF8String]);
[message release]; [message release];
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
......
...@@ -88,9 +88,10 @@ int macdrv_has_pasteboard_changed(void) ...@@ -88,9 +88,10 @@ int macdrv_has_pasteboard_changed(void)
*/ */
CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard)
{ {
@autoreleasepool
{
NSPasteboard* pb = (NSPasteboard*)pasteboard; NSPasteboard* pb = (NSPasteboard*)pasteboard;
__block CFArrayRef ret = NULL; __block CFArrayRef ret = NULL;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
dispatch_once(&BitmapOutputTypesInitOnce, ^{ dispatch_once(&BitmapOutputTypesInitOnce, ^{
NSArray* bitmapFileTypes = [NSArray arrayWithObjects: NSArray* bitmapFileTypes = [NSArray arrayWithObjects:
...@@ -138,9 +139,9 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) ...@@ -138,9 +139,9 @@ CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard)
} }
}); });
[pool release];
return ret; return ret;
} }
}
/*********************************************************************** /***********************************************************************
......
...@@ -58,8 +58,9 @@ static inline void convert_display_rect(CGRect* out_rect, NSRect in_rect, ...@@ -58,8 +58,9 @@ static inline void convert_display_rect(CGRect* out_rect, NSRect in_rect,
*/ */
int macdrv_get_displays(struct macdrv_display** displays, int* count) int macdrv_get_displays(struct macdrv_display** displays, int* count)
{ {
@autoreleasepool
{
int ret = -1; int ret = -1;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray* screens = [NSScreen screens]; NSArray* screens = [NSScreen screens];
if (screens) if (screens)
...@@ -95,9 +96,9 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count) ...@@ -95,9 +96,9 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count)
} }
} }
[pool release];
return ret; return ret;
} }
}
/*********************************************************************** /***********************************************************************
...@@ -191,11 +192,12 @@ done: ...@@ -191,11 +192,12 @@ done:
*/ */
static int macdrv_get_gpu_info_from_entry(struct macdrv_gpu* gpu, io_registry_entry_t entry) static int macdrv_get_gpu_info_from_entry(struct macdrv_gpu* gpu, io_registry_entry_t entry)
{ {
@autoreleasepool
{
io_registry_entry_t parent_entry; io_registry_entry_t parent_entry;
io_registry_entry_t gpu_entry; io_registry_entry_t gpu_entry;
kern_return_t result; kern_return_t result;
int ret = -1; int ret = -1;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
gpu_entry = entry; gpu_entry = entry;
while (![@"IOPCIDevice" isEqualToString:[(NSString*)IOObjectCopyClass(gpu_entry) autorelease]]) while (![@"IOPCIDevice" isEqualToString:[(NSString*)IOObjectCopyClass(gpu_entry) autorelease]])
...@@ -211,7 +213,6 @@ static int macdrv_get_gpu_info_from_entry(struct macdrv_gpu* gpu, io_registry_en ...@@ -211,7 +213,6 @@ static int macdrv_get_gpu_info_from_entry(struct macdrv_gpu* gpu, io_registry_en
} }
else if (result != kIOReturnSuccess) else if (result != kIOReturnSuccess)
{ {
[pool release];
return ret; return ret;
} }
...@@ -232,9 +233,9 @@ static int macdrv_get_gpu_info_from_entry(struct macdrv_gpu* gpu, io_registry_en ...@@ -232,9 +233,9 @@ static int macdrv_get_gpu_info_from_entry(struct macdrv_gpu* gpu, io_registry_en
done: done:
if (gpu_entry != entry) if (gpu_entry != entry)
IOObjectRelease(gpu_entry); IOObjectRelease(gpu_entry);
[pool release];
return ret; return ret;
} }
}
#ifdef HAVE_MTLDEVICE_REGISTRYID #ifdef HAVE_MTLDEVICE_REGISTRYID
...@@ -298,6 +299,8 @@ static int macdrv_get_gpu_info_from_mtldevice(struct macdrv_gpu* gpu, id<MTLDevi ...@@ -298,6 +299,8 @@ static int macdrv_get_gpu_info_from_mtldevice(struct macdrv_gpu* gpu, id<MTLDevi
*/ */
static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
{ {
@autoreleasepool
{
struct macdrv_gpu* gpus = NULL; struct macdrv_gpu* gpus = NULL;
struct macdrv_gpu primary_gpu; struct macdrv_gpu primary_gpu;
id<MTLDevice> primary_device; id<MTLDevice> primary_device;
...@@ -305,7 +308,6 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) ...@@ -305,7 +308,6 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
int primary_index = 0, i; int primary_index = 0, i;
int gpu_count = 0; int gpu_count = 0;
int ret = -1; int ret = -1;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
/* Test if Metal is available */ /* Test if Metal is available */
if (&MTLCopyAllDevices == NULL) if (&MTLCopyAllDevices == NULL)
...@@ -364,9 +366,9 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) ...@@ -364,9 +366,9 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
done: done:
if (ret) if (ret)
macdrv_free_gpus(gpus); macdrv_free_gpus(gpus);
[pool release];
return ret; return ret;
} }
}
/*********************************************************************** /***********************************************************************
* macdrv_get_gpu_info_from_display_id_using_metal * macdrv_get_gpu_info_from_display_id_using_metal
...@@ -377,9 +379,10 @@ done: ...@@ -377,9 +379,10 @@ done:
*/ */
static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gpu, CGDirectDisplayID display_id) static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gpu, CGDirectDisplayID display_id)
{ {
@autoreleasepool
{
id<MTLDevice> device; id<MTLDevice> device;
int ret = -1; int ret = -1;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
/* Test if Metal is available */ /* Test if Metal is available */
if (&CGDirectDisplayCopyCurrentMetalDevice == NULL) if (&CGDirectDisplayCopyCurrentMetalDevice == NULL)
...@@ -390,9 +393,9 @@ static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gp ...@@ -390,9 +393,9 @@ static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gp
ret = macdrv_get_gpu_info_from_registry_id(gpu, device.registryID); ret = macdrv_get_gpu_info_from_registry_id(gpu, device.registryID);
done: done:
[pool release];
return ret; return ret;
} }
}
#else #else
......
...@@ -292,7 +292,8 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -292,7 +292,8 @@ static const OSType WineHotKeySignature = 'Wine';
- (void) discardEventsPassingTest:(BOOL (^)(macdrv_event* event))block - (void) discardEventsPassingTest:(BOOL (^)(macdrv_event* event))block
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
NSIndexSet* indexes; NSIndexSet* indexes;
[eventsLock lock]; [eventsLock lock];
...@@ -305,8 +306,7 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -305,8 +306,7 @@ static const OSType WineHotKeySignature = 'Wine';
[events removeObjectsAtIndexes:indexes]; [events removeObjectsAtIndexes:indexes];
[eventsLock unlock]; [eventsLock unlock];
}
[pool release];
} }
- (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window - (void) discardEventsMatchingMask:(macdrv_event_mask)mask forWindow:(NSWindow*)window
...@@ -494,7 +494,8 @@ static const OSType WineHotKeySignature = 'Wine'; ...@@ -494,7 +494,8 @@ static const OSType WineHotKeySignature = 'Wine';
*/ */
void OnMainThread(dispatch_block_t block) void OnMainThread(dispatch_block_t block)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary];
WineEventQueue* queue = [threadDict objectForKey:WineEventQueueThreadDictionaryKey]; WineEventQueue* queue = [threadDict objectForKey:WineEventQueueThreadDictionaryKey];
dispatch_semaphore_t semaphore = NULL; dispatch_semaphore_t semaphore = NULL;
...@@ -523,21 +524,19 @@ void OnMainThread(dispatch_block_t block) ...@@ -523,21 +524,19 @@ void OnMainThread(dispatch_block_t block)
{ {
while (!finished) while (!finished)
{ {
MacDrvEvent* macDrvEvent; @autoreleasepool
struct kevent kev;
while (!finished &&
(macDrvEvent = [queue getEventMatchingMask:event_mask_for_type(QUERY_EVENT)]))
{ {
queue->event_handler(macDrvEvent->event); MacDrvEvent* macDrvEvent;
} struct kevent kev;
if (!finished) while (!finished &&
{ (macDrvEvent = [queue getEventMatchingMask:event_mask_for_type(QUERY_EVENT)]))
[pool release]; {
pool = [[NSAutoreleasePool alloc] init]; queue->event_handler(macDrvEvent->event);
}
kevent(queue->kq, NULL, 0, &kev, 1, NULL); if (!finished)
kevent(queue->kq, NULL, 0, &kev, 1, NULL);
} }
} }
} }
...@@ -546,8 +545,7 @@ void OnMainThread(dispatch_block_t block) ...@@ -546,8 +545,7 @@ void OnMainThread(dispatch_block_t block)
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore); dispatch_release(semaphore);
} }
}
[pool release];
} }
...@@ -559,7 +557,8 @@ void OnMainThread(dispatch_block_t block) ...@@ -559,7 +557,8 @@ void OnMainThread(dispatch_block_t block)
*/ */
macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler) macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary];
WineEventQueue* queue = [threadDict objectForKey:WineEventQueueThreadDictionaryKey]; WineEventQueue* queue = [threadDict objectForKey:WineEventQueueThreadDictionaryKey];
...@@ -575,9 +574,9 @@ macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler) ...@@ -575,9 +574,9 @@ macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler)
} }
} }
[pool release];
return (macdrv_event_queue)queue; return (macdrv_event_queue)queue;
} }
}
/*********************************************************************** /***********************************************************************
* macdrv_destroy_event_queue * macdrv_destroy_event_queue
...@@ -587,14 +586,14 @@ macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler) ...@@ -587,14 +586,14 @@ macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler)
*/ */
void macdrv_destroy_event_queue(macdrv_event_queue queue) void macdrv_destroy_event_queue(macdrv_event_queue queue)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineEventQueue* q = (WineEventQueue*)queue; WineEventQueue* q = (WineEventQueue*)queue;
NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary* threadDict = [[NSThread currentThread] threadDictionary];
[[WineApplicationController sharedController] unregisterEventQueue:q]; [[WineApplicationController sharedController] unregisterEventQueue:q];
[threadDict removeObjectForKey:WineEventQueueThreadDictionaryKey]; [threadDict removeObjectForKey:WineEventQueueThreadDictionaryKey];
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -622,16 +621,17 @@ int macdrv_get_event_queue_fd(macdrv_event_queue queue) ...@@ -622,16 +621,17 @@ int macdrv_get_event_queue_fd(macdrv_event_queue queue)
int macdrv_copy_event_from_queue(macdrv_event_queue queue, int macdrv_copy_event_from_queue(macdrv_event_queue queue,
macdrv_event_mask mask, macdrv_event **event) macdrv_event_mask mask, macdrv_event **event)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineEventQueue* q = (WineEventQueue*)queue; WineEventQueue* q = (WineEventQueue*)queue;
MacDrvEvent* macDrvEvent = [q getEventMatchingMask:mask]; MacDrvEvent* macDrvEvent = [q getEventMatchingMask:mask];
if (macDrvEvent) if (macDrvEvent)
*event = macdrv_retain_event(macDrvEvent->event); *event = macdrv_retain_event(macDrvEvent->event);
[pool release];
return (macDrvEvent != nil); return (macDrvEvent != nil);
} }
}
/*********************************************************************** /***********************************************************************
* macdrv_create_event * macdrv_create_event
...@@ -666,10 +666,10 @@ macdrv_event* macdrv_retain_event(macdrv_event *event) ...@@ -666,10 +666,10 @@ macdrv_event* macdrv_retain_event(macdrv_event *event)
*/ */
void macdrv_release_event(macdrv_event *event) void macdrv_release_event(macdrv_event *event)
{ {
@autoreleasepool
{
if (OSAtomicDecrement32Barrier(&event->refs) <= 0) if (OSAtomicDecrement32Barrier(&event->refs) <= 0)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
switch (event->type) switch (event->type)
{ {
case IM_SET_TEXT: case IM_SET_TEXT:
...@@ -691,10 +691,9 @@ void macdrv_release_event(macdrv_event *event) ...@@ -691,10 +691,9 @@ void macdrv_release_event(macdrv_event *event)
[(WineWindow*)event->window release]; [(WineWindow*)event->window release];
free(event); free(event);
[pool release];
} }
} }
}
/*********************************************************************** /***********************************************************************
* macdrv_create_query * macdrv_create_query
......
...@@ -64,35 +64,37 @@ static void run_cocoa_app(void* info) ...@@ -64,35 +64,37 @@ static void run_cocoa_app(void* info)
NSConditionLock* lock = startup_info->lock; NSConditionLock* lock = startup_info->lock;
BOOL created_app = FALSE; BOOL created_app = FALSE;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
if (!NSApp)
{
[WineApplication sharedApplication];
created_app = TRUE;
}
if ([NSApp respondsToSelector:@selector(setWineController:)])
{ {
WineApplicationController* controller = [WineApplicationController sharedController]; if (!NSApp)
[NSApp setWineController:controller]; {
[controller computeEventTimeAdjustmentFromTicks:startup_info->tickcount uptime:startup_info->uptime_ns]; [WineApplication sharedApplication];
startup_info->success = TRUE; created_app = TRUE;
} }
/* Retain the lock while we're using it, so macdrv_start_cocoa_app() if ([NSApp respondsToSelector:@selector(setWineController:)])
doesn't deallocate it in the middle of us unlocking it. */ {
[lock retain]; WineApplicationController* controller = [WineApplicationController sharedController];
[lock lock]; [NSApp setWineController:controller];
[lock unlockWithCondition:COCOA_APP_RUNNING]; [controller computeEventTimeAdjustmentFromTicks:startup_info->tickcount uptime:startup_info->uptime_ns];
[lock release]; startup_info->success = TRUE;
}
[pool release]; /* Retain the lock while we're using it, so macdrv_start_cocoa_app()
doesn't deallocate it in the middle of us unlocking it. */
[lock retain];
[lock lock];
[lock unlockWithCondition:COCOA_APP_RUNNING];
[lock release];
}
if (created_app && startup_info->success) if (created_app && startup_info->success)
{ {
/* Never returns */ @autoreleasepool
[NSApp run]; {
/* Never returns */
[NSApp run];
}
} }
} }
...@@ -106,6 +108,8 @@ static void run_cocoa_app(void* info) ...@@ -106,6 +108,8 @@ static void run_cocoa_app(void* info)
*/ */
int macdrv_start_cocoa_app(unsigned long long tickcount) int macdrv_start_cocoa_app(unsigned long long tickcount)
{ {
@autoreleasepool
{
int ret = -1; int ret = -1;
CFRunLoopSourceRef source; CFRunLoopSourceRef source;
struct cocoa_app_startup_info startup_info; struct cocoa_app_startup_info startup_info;
...@@ -114,8 +118,6 @@ int macdrv_start_cocoa_app(unsigned long long tickcount) ...@@ -114,8 +118,6 @@ int macdrv_start_cocoa_app(unsigned long long tickcount)
NSDate* timeLimit; NSDate* timeLimit;
CFRunLoopSourceContext source_context = { 0 }; CFRunLoopSourceContext source_context = { 0 };
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/* Make sure Cocoa is in multi-threading mode by detaching a /* Make sure Cocoa is in multi-threading mode by detaching a
do-nothing thread. */ do-nothing thread. */
[NSThread detachNewThreadSelector:@selector(self) [NSThread detachNewThreadSelector:@selector(self)
...@@ -151,6 +153,6 @@ int macdrv_start_cocoa_app(unsigned long long tickcount) ...@@ -151,6 +153,6 @@ int macdrv_start_cocoa_app(unsigned long long tickcount)
if (source) if (source)
CFRelease(source); CFRelease(source);
[startup_info.lock release]; [startup_info.lock release];
[pool release];
return ret; return ret;
} }
}
...@@ -242,14 +242,15 @@ ...@@ -242,14 +242,15 @@
*/ */
macdrv_opengl_context macdrv_create_opengl_context(void* cglctx) macdrv_opengl_context macdrv_create_opengl_context(void* cglctx)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineOpenGLContext *context; WineOpenGLContext *context;
context = [[WineOpenGLContext alloc] initWithCGLContextObj:cglctx]; context = [[WineOpenGLContext alloc] initWithCGLContextObj:cglctx];
[pool release];
return (macdrv_opengl_context)context; return (macdrv_opengl_context)context;
} }
}
/*********************************************************************** /***********************************************************************
* macdrv_dispose_opengl_context * macdrv_dispose_opengl_context
...@@ -259,13 +260,13 @@ macdrv_opengl_context macdrv_create_opengl_context(void* cglctx) ...@@ -259,13 +260,13 @@ macdrv_opengl_context macdrv_create_opengl_context(void* cglctx)
*/ */
void macdrv_dispose_opengl_context(macdrv_opengl_context c) void macdrv_dispose_opengl_context(macdrv_opengl_context c)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
[context removeFromViews:YES]; [context removeFromViews:YES];
[context release]; [context release];
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -273,7 +274,8 @@ void macdrv_dispose_opengl_context(macdrv_opengl_context c) ...@@ -273,7 +274,8 @@ void macdrv_dispose_opengl_context(macdrv_opengl_context c)
*/ */
void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect r) void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect r)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
NSView* view = (NSView*)v; NSView* view = (NSView*)v;
...@@ -328,8 +330,7 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect ...@@ -328,8 +330,7 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect
if (context) if (context)
[context removeFromViews:YES]; [context removeFromViews:YES];
} }
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -337,7 +338,8 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect ...@@ -337,7 +338,8 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect
*/ */
void macdrv_update_opengl_context(macdrv_opengl_context c) void macdrv_update_opengl_context(macdrv_opengl_context c)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
if (context.needsUpdate) if (context.needsUpdate)
...@@ -367,8 +369,7 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) ...@@ -367,8 +369,7 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
[context resetSurfaceIfBackingSizeChanged]; [context resetSurfaceIfBackingSizeChanged];
} }
} }
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -379,11 +380,11 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) ...@@ -379,11 +380,11 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
*/ */
void macdrv_flush_opengl_context(macdrv_opengl_context c) void macdrv_flush_opengl_context(macdrv_opengl_context c)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
macdrv_update_opengl_context(c); macdrv_update_opengl_context(c);
[context flushBuffer]; [context flushBuffer];
}
[pool release];
} }
...@@ -3282,7 +3282,8 @@ macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf ...@@ -3282,7 +3282,8 @@ macdrv_window macdrv_create_cocoa_window(const struct macdrv_window_features* wf
*/ */
void macdrv_destroy_cocoa_window(macdrv_window w) void macdrv_destroy_cocoa_window(macdrv_window w)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThread(^{ OnMainThread(^{
...@@ -3292,8 +3293,7 @@ void macdrv_destroy_cocoa_window(macdrv_window w) ...@@ -3292,8 +3293,7 @@ void macdrv_destroy_cocoa_window(macdrv_window w)
}); });
[window.queue discardEventsMatchingMask:-1 forWindow:window]; [window.queue discardEventsMatchingMask:-1 forWindow:window];
[window release]; [window release];
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3345,7 +3345,8 @@ void macdrv_set_cocoa_window_state(macdrv_window w, ...@@ -3345,7 +3345,8 @@ void macdrv_set_cocoa_window_state(macdrv_window w,
void macdrv_set_cocoa_window_title(macdrv_window w, const unsigned short* title, void macdrv_set_cocoa_window_title(macdrv_window w, const unsigned short* title,
size_t length) size_t length)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
NSString* titleString; NSString* titleString;
...@@ -3358,8 +3359,7 @@ void macdrv_set_cocoa_window_title(macdrv_window w, const unsigned short* title, ...@@ -3358,8 +3359,7 @@ void macdrv_set_cocoa_window_title(macdrv_window w, const unsigned short* title,
if ([window isOrderedIn] && ![window isExcludedFromWindowsMenu]) if ([window isOrderedIn] && ![window isExcludedFromWindowsMenu])
[NSApp changeWindowsItem:window title:titleString filename:NO]; [NSApp changeWindowsItem:window title:titleString filename:NO];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3454,15 +3454,15 @@ void macdrv_set_cocoa_parent_window(macdrv_window w, macdrv_window parent) ...@@ -3454,15 +3454,15 @@ void macdrv_set_cocoa_parent_window(macdrv_window w, macdrv_window parent)
*/ */
void macdrv_set_window_surface(macdrv_window w, void *surface, pthread_mutex_t *mutex) void macdrv_set_window_surface(macdrv_window w, void *surface, pthread_mutex_t *mutex)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThread(^{ OnMainThread(^{
window.surface = surface; window.surface = surface;
window.surface_mutex = mutex; window.surface_mutex = mutex;
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3473,14 +3473,14 @@ void macdrv_set_window_surface(macdrv_window w, void *surface, pthread_mutex_t * ...@@ -3473,14 +3473,14 @@ void macdrv_set_window_surface(macdrv_window w, void *surface, pthread_mutex_t *
*/ */
void macdrv_window_needs_display(macdrv_window w, CGRect rect) void macdrv_window_needs_display(macdrv_window w, CGRect rect)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThreadAsync(^{ OnMainThreadAsync(^{
[[window contentView] setNeedsDisplayInRect:NSRectFromCGRect(cgrect_mac_from_win(rect))]; [[window contentView] setNeedsDisplayInRect:NSRectFromCGRect(cgrect_mac_from_win(rect))];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3491,7 +3491,8 @@ void macdrv_window_needs_display(macdrv_window w, CGRect rect) ...@@ -3491,7 +3491,8 @@ void macdrv_window_needs_display(macdrv_window w, CGRect rect)
*/ */
void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count) void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThread(^{ OnMainThread(^{
...@@ -3512,8 +3513,7 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count) ...@@ -3512,8 +3513,7 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
CGPathRelease(path); CGPathRelease(path);
} }
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3521,12 +3521,12 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count) ...@@ -3521,12 +3521,12 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
*/ */
void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha) void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
[window setAlphaValue:alpha]; [window setAlphaValue:alpha];
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3535,7 +3535,8 @@ void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha) ...@@ -3535,7 +3535,8 @@ void macdrv_set_window_alpha(macdrv_window w, CGFloat alpha)
void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGreen, void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGreen,
CGFloat keyBlue) CGFloat keyBlue)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThread(^{ OnMainThread(^{
...@@ -3545,8 +3546,7 @@ void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGre ...@@ -3545,8 +3546,7 @@ void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGre
window.colorKeyBlue = keyBlue; window.colorKeyBlue = keyBlue;
[window checkTransparency]; [window checkTransparency];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3554,15 +3554,15 @@ void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGre ...@@ -3554,15 +3554,15 @@ void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat keyGre
*/ */
void macdrv_clear_window_color_key(macdrv_window w) void macdrv_clear_window_color_key(macdrv_window w)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThread(^{ OnMainThread(^{
window.colorKeyed = FALSE; window.colorKeyed = FALSE;
[window checkTransparency]; [window checkTransparency];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3570,15 +3570,15 @@ void macdrv_clear_window_color_key(macdrv_window w) ...@@ -3570,15 +3570,15 @@ void macdrv_clear_window_color_key(macdrv_window w)
*/ */
void macdrv_window_use_per_pixel_alpha(macdrv_window w, int use_per_pixel_alpha) void macdrv_window_use_per_pixel_alpha(macdrv_window w, int use_per_pixel_alpha)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
OnMainThread(^{ OnMainThread(^{
window.usePerPixelAlpha = use_per_pixel_alpha; window.usePerPixelAlpha = use_per_pixel_alpha;
[window checkTransparency]; [window checkTransparency];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3620,7 +3620,8 @@ void macdrv_set_window_min_max_sizes(macdrv_window w, CGSize min_size, CGSize ma ...@@ -3620,7 +3620,8 @@ void macdrv_set_window_min_max_sizes(macdrv_window w, CGSize min_size, CGSize ma
*/ */
macdrv_view macdrv_create_view(CGRect rect) macdrv_view macdrv_create_view(CGRect rect)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
__block WineContentView* view; __block WineContentView* view;
if (CGRectIsNull(rect)) rect = CGRectZero; if (CGRectIsNull(rect)) rect = CGRectZero;
...@@ -3642,9 +3643,9 @@ macdrv_view macdrv_create_view(CGRect rect) ...@@ -3642,9 +3643,9 @@ macdrv_view macdrv_create_view(CGRect rect)
object:NSApp]; object:NSApp];
}); });
[pool release];
return (macdrv_view)view; return (macdrv_view)view;
} }
}
/*********************************************************************** /***********************************************************************
* macdrv_dispose_view * macdrv_dispose_view
...@@ -3653,7 +3654,8 @@ macdrv_view macdrv_create_view(CGRect rect) ...@@ -3653,7 +3654,8 @@ macdrv_view macdrv_create_view(CGRect rect)
*/ */
void macdrv_dispose_view(macdrv_view v) void macdrv_dispose_view(macdrv_view v)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineContentView* view = (WineContentView*)v; WineContentView* view = (WineContentView*)v;
OnMainThread(^{ OnMainThread(^{
...@@ -3670,8 +3672,7 @@ void macdrv_dispose_view(macdrv_view v) ...@@ -3670,8 +3672,7 @@ void macdrv_dispose_view(macdrv_view v)
[view release]; [view release];
[window updateForGLSubviews]; [window updateForGLSubviews];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3679,7 +3680,8 @@ void macdrv_dispose_view(macdrv_view v) ...@@ -3679,7 +3680,8 @@ void macdrv_dispose_view(macdrv_view v)
*/ */
void macdrv_set_view_frame(macdrv_view v, CGRect rect) void macdrv_set_view_frame(macdrv_view v, CGRect rect)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineContentView* view = (WineContentView*)v; WineContentView* view = (WineContentView*)v;
if (CGRectIsNull(rect)) rect = CGRectZero; if (CGRectIsNull(rect)) rect = CGRectZero;
...@@ -3707,8 +3709,7 @@ void macdrv_set_view_frame(macdrv_view v, CGRect rect) ...@@ -3707,8 +3709,7 @@ void macdrv_set_view_frame(macdrv_view v, CGRect rect)
[(WineWindow*)[view window] updateForGLSubviews]; [(WineWindow*)[view window] updateForGLSubviews];
} }
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3721,7 +3722,8 @@ void macdrv_set_view_frame(macdrv_view v, CGRect rect) ...@@ -3721,7 +3722,8 @@ void macdrv_set_view_frame(macdrv_view v, CGRect rect)
*/ */
void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, macdrv_view p, macdrv_view n) void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, macdrv_view p, macdrv_view n)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineContentView* view = (WineContentView*)v; WineContentView* view = (WineContentView*)v;
WineContentView* superview = (WineContentView*)s; WineContentView* superview = (WineContentView*)s;
WineWindow* window = (WineWindow*)w; WineWindow* window = (WineWindow*)w;
...@@ -3762,8 +3764,7 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma ...@@ -3762,8 +3764,7 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma
[newWindow updateForGLSubviews]; [newWindow updateForGLSubviews];
} }
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3771,15 +3772,15 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma ...@@ -3771,15 +3772,15 @@ void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, ma
*/ */
void macdrv_set_view_hidden(macdrv_view v, int hidden) void macdrv_set_view_hidden(macdrv_view v, int hidden)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineContentView* view = (WineContentView*)v; WineContentView* view = (WineContentView*)v;
OnMainThreadAsync(^{ OnMainThreadAsync(^{
[view setHidden:hidden]; [view setHidden:hidden];
[(WineWindow*)view.window updateForGLSubviews]; [(WineWindow*)view.window updateForGLSubviews];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3789,15 +3790,15 @@ void macdrv_set_view_hidden(macdrv_view v, int hidden) ...@@ -3789,15 +3790,15 @@ void macdrv_set_view_hidden(macdrv_view v, int hidden)
*/ */
void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineContentView* view = (WineContentView*)v; WineContentView* view = (WineContentView*)v;
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
OnMainThread(^{ OnMainThread(^{
[view addGLContext:context]; [view addGLContext:context];
}); });
}
[pool release];
} }
/*********************************************************************** /***********************************************************************
...@@ -3807,19 +3808,21 @@ void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) ...@@ -3807,19 +3808,21 @@ void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c)
*/ */
void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c) void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
WineContentView* view = (WineContentView*)v; WineContentView* view = (WineContentView*)v;
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
OnMainThreadAsync(^{ OnMainThreadAsync(^{
[view removeGLContext:context]; [view removeGLContext:context];
}); });
}
[pool release];
} }
macdrv_metal_device macdrv_create_metal_device(void) macdrv_metal_device macdrv_create_metal_device(void)
{ {
@autoreleasepool
{
macdrv_metal_device ret; macdrv_metal_device ret;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
...@@ -3827,17 +3830,17 @@ macdrv_metal_device macdrv_create_metal_device(void) ...@@ -3827,17 +3830,17 @@ macdrv_metal_device macdrv_create_metal_device(void)
return NULL; return NULL;
#endif #endif
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
ret = (macdrv_metal_device)MTLCreateSystemDefaultDevice(); ret = (macdrv_metal_device)MTLCreateSystemDefaultDevice();
[pool release];
return ret; return ret;
} }
}
void macdrv_release_metal_device(macdrv_metal_device d) void macdrv_release_metal_device(macdrv_metal_device d)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool
{
[(id<MTLDevice>)d release]; [(id<MTLDevice>)d release];
[pool release]; }
} }
macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d) macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment