summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2015-03-21 00:44:51 (GMT)
committerKevin Walzer <kw@codebykevin.com>2015-03-21 00:44:51 (GMT)
commitc76fcabd431431b1acfc9d4113781872fcc9fe9b (patch)
tree9c31348825d0133c3800fb172836376aabbb89e8
parentc9882c7aeaae398fd75018012a712567852fd788 (diff)
downloadtk-c76fcabd431431b1acfc9d4113781872fcc9fe9b.zip
tk-c76fcabd431431b1acfc9d4113781872fcc9fe9b.tar.gz
tk-c76fcabd431431b1acfc9d4113781872fcc9fe9b.tar.bz2
Remove garbage collections calls as GC is no longer supported on OS X; thanks to Marc Culler for patch
-rw-r--r--macosx/tkMacOSXCursor.c5
-rw-r--r--macosx/tkMacOSXFont.c5
-rw-r--r--macosx/tkMacOSXInit.c2
-rw-r--r--macosx/tkMacOSXMenu.c24
-rw-r--r--macosx/tkMacOSXNotify.c10
-rw-r--r--macosx/tkMacOSXPrivate.h18
-rw-r--r--macosx/tkMacOSXWm.c22
-rw-r--r--macosx/tkMacOSXXStubs.c3
8 files changed, 36 insertions, 53 deletions
diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c
index 53c2cd2..b6394b7 100644
--- a/macosx/tkMacOSXCursor.c
+++ b/macosx/tkMacOSXCursor.c
@@ -344,7 +344,7 @@ FindCursorByName(
macCursor = [[NSCursor alloc] initWithImage:image hotSpot:hotSpot];
[image release];
}
- macCursorPtr->macCursor = TkMacOSXMakeUncollectable(macCursor);
+ macCursorPtr->macCursor = macCursor;
}
/*
@@ -454,7 +454,8 @@ TkpFreeCursor(
{
TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr;
- TkMacOSXMakeCollectableAndRelease(macCursorPtr->macCursor);
+ [macCursorPtr->macCursor release];
+ macCursorPtr->macCursor = NULL;
if (macCursorPtr == gCurrentCursor) {
gCurrentCursor = NULL;
}
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 4c8ac30..45a68f7 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -293,7 +293,7 @@ InitFont(
[NSNumber numberWithInt:fmPtr->fixed ? 0 : 1],
NSLigatureAttributeName,
[NSNumber numberWithDouble:kern], NSKernAttributeName, nil];
- fontPtr->nsAttributes = TkMacOSXMakeUncollectableAndRetain(nsAttributes);
+ fontPtr->nsAttributes = [nsAttributes retain];
#undef nCh
}
@@ -557,7 +557,8 @@ TkpDeleteFont(
{
MacFont *fontPtr = (MacFont *) tkFontPtr;
- TkMacOSXMakeCollectableAndRelease(fontPtr->nsAttributes);
+ [fontPtr->nsAttributes release];
+ fontPtr->nsAttributes = NULL;
CFRelease(fontPtr->nsFont); /* Either a CTFontRef or a CFRetained NSFont */
}
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 6a881d3..e861089 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -28,7 +28,6 @@ static char tkLibPath[PATH_MAX + 1] = "";
static char scriptPath[PATH_MAX + 1] = "";
-int tkMacOSXGCEnabled = 0;
long tkMacOSXMacOSXVersion = 0;
#pragma mark TKApplication(TKInit)
@@ -258,7 +257,6 @@ TkpInit(
if (!pool) {
pool = [NSAutoreleasePool new];
}
- tkMacOSXGCEnabled = ([NSGarbageCollector defaultCollector] != nil);
[[NSUserDefaults standardUserDefaults] registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index ecdf1ab..9f14f47 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -496,8 +496,7 @@ TkpNewMenu(
* platform structure for. */
{
TKMenu *menu = [[TKMenu alloc] initWithTkMenu:menuPtr];
- menuPtr->platformData = (TkMenuPlatformData)
- TkMacOSXMakeUncollectable(menu);
+ menuPtr->platformData = (TkMenuPlatformData) menu;
CheckForSpecialMenu(menuPtr);
return TCL_OK;
}
@@ -522,7 +521,10 @@ void
TkpDestroyMenu(
TkMenu *menuPtr) /* The common menu structure */
{
- TkMacOSXMakeCollectableAndRelease(menuPtr->platformData);
+ NSMenu* nsmenu = (NSMenu*)(menuPtr->platformData);
+
+ [nsmenu release];
+ menuPtr->platformData = NULL;
}
/*
@@ -555,8 +557,7 @@ TkpMenuNewEntry(
} else {
menuItem = [menu newTkMenuItem:mePtr];
}
- mePtr->platformEntryData = (TkMenuPlatformEntryData)
- TkMacOSXMakeUncollectable(menuItem);
+ mePtr->platformEntryData = (TkMenuPlatformEntryData) menuItem;
/*
* Caller TkMenuEntry() already did this same insertion into the generic
@@ -720,16 +721,21 @@ void
TkpDestroyMenuEntry(
TkMenuEntry *mePtr)
{
+ NSMenuItem *menuItem;
+ TKMenu *menu;
+ NSInteger index;
+
if (mePtr->platformEntryData && mePtr->menuPtr->platformData) {
- TKMenu *menu = (TKMenu *) mePtr->menuPtr->platformData;
- NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData;
- NSInteger index = [menu indexOfItem:menuItem];
+ menu = (TKMenu *) mePtr->menuPtr->platformData;
+ menuItem = (NSMenuItem *) mePtr->platformEntryData;
+ index = [menu indexOfItem:menuItem];
if (index > -1) {
[menu removeItemAtIndex:index];
}
+ [menuItem release];
+ mePtr->platformEntryData = NULL;
}
- TkMacOSXMakeCollectableAndRelease(mePtr->platformEntryData);
}
/*
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c
index 3e0dfde..ab68931 100644
--- a/macosx/tkMacOSXNotify.c
+++ b/macosx/tkMacOSXNotify.c
@@ -234,8 +234,7 @@ TkMacOSXEventsSetupProc(
dequeue:YES];
if (currentEvent) {
- tsdPtr->currentEvent =
- TkMacOSXMakeUncollectableAndRetain(currentEvent);
+ tsdPtr->currentEvent = [currentEvent retain];
}
}
if (tsdPtr->currentEvent) {
@@ -273,8 +272,8 @@ TkMacOSXEventsCheckProc(
TSD_INIT();
if (tsdPtr->currentEvent) {
- currentEvent = TkMacOSXMakeCollectableAndAutorelease(
- tsdPtr->currentEvent);
+ currentEvent = tsdPtr->currentEvent;
+ [currentEvent autorelease];
}
do {
modalSession = TkMacOSXGetModalSession();
@@ -288,9 +287,6 @@ TkMacOSXEventsCheckProc(
}
[currentEvent retain];
pool = [NSAutoreleasePool new];
- if (tkMacOSXGCEnabled) {
- objc_clear_stack(0);
- }
if (![NSApp tkProcessEvent:currentEvent]) {
[currentEvent release];
currentEvent = nil;
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 3664850..2de3673 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -144,23 +144,6 @@
}
/*
- * Macros for GC
- */
-
-#define TkMacOSXMakeUncollectable(x) ({ id o = (id)(x); \
- if (o) { if(tkMacOSXGCEnabled) CFRetain(o); } o; })
-#define TkMacOSXMakeUncollectableAndRetain(x) ({ id o = (id)(x); \
- if (o) { if(tkMacOSXGCEnabled) CFRetain(o); else [o retain]; } o; })
-#define TkMacOSXMakeCollectable(x) ({ id o = (id)(x); \
- if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); } o; })
-#define TkMacOSXMakeCollectableAndRelease(x) ({ id o = (id)(x); \
- if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \
- else [o release]; } o; })
-#define TkMacOSXMakeCollectableAndAutorelease(x) ({ id o = (id)(x); \
- if (o) { x = nil; if (tkMacOSXGCEnabled) CFRelease(o); \
- else [o autorelease]; } o; })
-
-/*
* Structure encapsulating current drawing environment.
*/
@@ -178,7 +161,6 @@ typedef struct TkMacOSXDrawingContext {
MODULE_SCOPE CGFloat tkMacOSXZeroScreenHeight;
MODULE_SCOPE CGFloat tkMacOSXZeroScreenTop;
-MODULE_SCOPE int tkMacOSXGCEnabled;
MODULE_SCOPE long tkMacOSXMacOSXVersion;
/*
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 429d7aa..fc61c7f 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -786,17 +786,18 @@ TkWmDeadWindow(
[[window parentWindow] removeChildWindow:window];
[window setExcludedFromWindowsMenu:YES];
[window close];
- TkMacOSXUnregisterMacWindow(window);
- if (winPtr->window) {
- ((MacDrawable *) winPtr->window)->view = nil;
+ TkMacOSXUnregisterMacWindow(window);
+ if (winPtr->window) {
+ ((MacDrawable *) winPtr->window)->view = nil;
}
- TkMacOSXMakeCollectableAndRelease(wmPtr->window);
- /* Activate the highest window left on the screen. */
- NSArray *windows = [NSApp orderedWindows];
- NSWindow *front = [windows objectAtIndex:0];
- if ( front && [front canBecomeKeyWindow] ) {
- [front makeKeyAndOrderFront:NSApp];
- }
+ [window release];
+ wmPtr->window = NULL;
+ /* Activate the highest window left on the screen. */
+ NSArray *windows = [NSApp orderedWindows];
+ NSWindow *front = [windows objectAtIndex:0];
+ if ( front && [front canBecomeKeyWindow] ) {
+ [front makeKeyAndOrderFront:NSApp];
+ }
}
ckfree(wmPtr);
winPtr->wmInfoPtr = NULL;
@@ -5486,7 +5487,6 @@ TkMacOSXMakeRealWindowExist(
if (!window) {
Tcl_Panic("couldn't allocate new Mac window");
}
- TkMacOSXMakeUncollectable(window);
TKContentView *contentView = [[TKContentView alloc]
initWithFrame:NSZeroRect];
[window setContentView:contentView];
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index b16b582..e03260f 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -177,8 +177,7 @@ TkpOpenDisplay(
display->proto_minor_version = [[cgVers objectAtIndex:2] integerValue];
}
if (!vendor[0]) {
- snprintf(vendor, sizeof(vendor), "Apple AppKit %s %g",
- ([NSGarbageCollector defaultCollector] ? "GC" : "RR"),
+ snprintf(vendor, sizeof(vendor), "Apple AppKit %g",
NSAppKitVersionNumber);
}
display->vendor = vendor;