Permalink
Browse files

fixed a crasher where references to dealloced global vars were left a…

…round,

and things just went south when you tried to startup another JSCocoaController
after the last one had been dealloc'd

Signed-off-by: Patrick Geiller <parmanoir@gmail.com>
  • Loading branch information...
1 parent f260b28 commit 8cb14d5fb329f2504eeb696140a18538d6289d45 @ccgus ccgus committed with Sep 13, 2009
@@ -329,6 +329,8 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1)";
+ ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1 = x86_64;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
View
@@ -11,6 +11,10 @@
int main(int argc, char *argv[])
{
+#ifdef __LP64__
+ printf("__LP64__!\n");
+#endif
+
id pool = [[NSAutoreleasePool alloc] init];
id c = [JSCocoaController sharedController];
@@ -254,22 +254,44 @@ - (void)cleanUp
[self setUseSafeDealloc:NO];
[self unlinkAllReferences];
JSGarbageCollect(ctx);
-
+
controllerCount--;
if (controllerCount == 0)
{
- if (OSXObjectClass) JSClassRelease(OSXObjectClass);
- if (jsCocoaObjectClass) JSClassRelease(jsCocoaObjectClass);
- if (hashObjectClass) JSClassRelease(hashObjectClass);
-
+ if (OSXObjectClass) {
+ JSClassRelease(OSXObjectClass);
+ OSXObjectClass = nil;
+ }
+
+ if (jsCocoaObjectClass) {
+ JSClassRelease(jsCocoaObjectClass);
+ jsCocoaObjectClass = nil;
+ }
+
+ if (hashObjectClass) {
+ JSClassRelease(hashObjectClass);
+ hashObjectClass = nil;
+ }
+
+ // we need to nil these all out, since they are static
+ // and if we make another JSCocoaController after this- they will
+ // still be around and that's kinda bad (like crashing bad).
[sharedInstanceStats release];
+ sharedInstanceStats = nil;
[closureHash release];
+ closureHash = nil;
[jsFunctionSelectors release];
+ jsFunctionSelectors = nil;
[jsFunctionClasses release];
+ jsFunctionClasses = nil;
[jsFunctionHash release];
+ jsFunctionHash = nil;
[splitCallCache release];
+ splitCallCache = nil;
[jsClassParents release];
+ jsClassParents = nil;
[boxedObjects release];
+ boxedObjects = nil;
}
JSGlobalContextRelease(ctx);
@@ -327,7 +327,7 @@
C05733CC08A9546B00998B17 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -12,6 +12,7 @@
Method('add:and:').encoding('int int int').fn = function(a, b)
{
log('Objc class method adding ' + a + ' and ' + b)
+ log(NSMakeRect(1, 1, 1, 1));
return a+b+magic
}
}

0 comments on commit 8cb14d5

Please sign in to comment.