xquartz: Use objc_autoreleasePoolPush / objc_autoreleasePoolPop directly in QuartzBlockHandler
It violates @autoreleasepool best practices, and this helps collapse quartzCocoa.m into quartz.c Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
parent
fba421f700
commit
94e4e17348
|
@ -30,7 +30,6 @@ libXquartz_la_SOURCES = \
|
|||
darwinXinput.c \
|
||||
keysym2ucs.c \
|
||||
quartz.c \
|
||||
quartzCocoa.m \
|
||||
quartzKeyboard.c \
|
||||
quartzStartup.c \
|
||||
quartzRandR.c
|
||||
|
|
|
@ -72,6 +72,15 @@
|
|||
#include <rootlessCommon.h>
|
||||
#include <Xplugin.h>
|
||||
|
||||
// These are vended by the Objective-C runtime, but they are unfortunately
|
||||
// not available as API in the macOS SDK. We are following suit with swift
|
||||
// and clang in declaring them inline here. They canot be removed or changed
|
||||
// in the OS without major bincompat ramifications.
|
||||
//
|
||||
// These were added in macOS 10.7.
|
||||
void * _Nonnull objc_autoreleasePoolPush(void);
|
||||
void objc_autoreleasePoolPop(void * _Nonnull context);
|
||||
|
||||
DevPrivateKeyRec quartzScreenKeyRec;
|
||||
int aquaMenuBarHeight = 0;
|
||||
QuartzModeProcsPtr quartzProcs = NULL;
|
||||
|
@ -143,6 +152,30 @@ QuartzSetupScreen(int index,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* QuartzBlockHandler
|
||||
* Clean out any autoreleased objects.
|
||||
*/
|
||||
static void
|
||||
QuartzBlockHandler(void *blockData, void *pTimeout)
|
||||
{
|
||||
static void *poolToken = NULL;
|
||||
|
||||
if (poolToken) {
|
||||
objc_autoreleasePoolPop(poolToken);
|
||||
}
|
||||
poolToken = objc_autoreleasePoolPush();
|
||||
}
|
||||
|
||||
/*
|
||||
* QuartzWakeupHandler
|
||||
*/
|
||||
static void
|
||||
QuartzWakeupHandler(void *blockData, int result)
|
||||
{
|
||||
/* nothing here */
|
||||
}
|
||||
|
||||
/*
|
||||
* QuartzInitOutput
|
||||
* Quartz display initialization.
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/**************************************************************
|
||||
*
|
||||
* Quartz-specific support for the Darwin X Server
|
||||
* that requires Cocoa and Objective-C.
|
||||
*
|
||||
* This file is separate from the parts of Quartz support
|
||||
* that use X include files to avoid symbol collisions.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name(s) of the above copyright
|
||||
* holders shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in this Software without prior written authorization.
|
||||
*/
|
||||
|
||||
#include "sanitizedCocoa.h"
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include "quartzCommon.h"
|
||||
#include "inputstr.h"
|
||||
|
||||
#include "darwin.h"
|
||||
|
||||
/*
|
||||
* QuartzBlockHandler
|
||||
* Clean out any autoreleased objects.
|
||||
*/
|
||||
void
|
||||
QuartzBlockHandler(void *blockData, void *pTimeout)
|
||||
{
|
||||
static NSAutoreleasePool *aPool = nil;
|
||||
|
||||
[aPool release];
|
||||
aPool = [[NSAutoreleasePool alloc] init];
|
||||
}
|
||||
|
||||
/*
|
||||
* QuartzWakeupHandler
|
||||
*/
|
||||
void
|
||||
QuartzWakeupHandler(void *blockData, int result)
|
||||
{
|
||||
// nothing here
|
||||
}
|
|
@ -46,10 +46,4 @@ extern int aquaMenuBarHeight;
|
|||
// Name of GLX bundle for native OpenGL
|
||||
extern const char *quartzOpenGLBundle;
|
||||
|
||||
void
|
||||
QuartzBlockHandler(void *blockData, void *pTimeout);
|
||||
|
||||
void
|
||||
QuartzWakeupHandler(void *blockData, int result);
|
||||
|
||||
#endif /* _QUARTZCOMMON_H */
|
||||
|
|
Loading…
Reference in New Issue