Skip to content
This repository
Browse code

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...
commit 8cb14d5fb329f2504eeb696140a18538d6289d45 1 parent f260b28
August "Gus" Mueller authored September 14, 2009 parmanoir committed September 14, 2009
2  GUIConsole/JSCocoa.xcodeproj/project.pbxproj
@@ -329,6 +329,8 @@
329 329
 		C01FCF4F08A954540054247B /* Debug */ = {
330 330
 			isa = XCBuildConfiguration;
331 331
 			buildSettings = {
  332
+				ARCHS = "$(ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1)";
  333
+				ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1 = x86_64;
332 334
 				GCC_C_LANGUAGE_STANDARD = c99;
333 335
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
334 336
 				GCC_WARN_UNUSED_VARIABLE = YES;
4  GUIConsole/main.m
@@ -11,6 +11,10 @@
11 11
 
12 12
 int main(int argc, char *argv[])
13 13
 {
  14
+#ifdef __LP64__
  15
+    printf("__LP64__!\n");
  16
+#endif
  17
+
14 18
 	id pool = [[NSAutoreleasePool alloc] init];
15 19
 	
16 20
 	id c = [JSCocoaController sharedController];
32  JSCocoa/JSCocoaController.m
@@ -254,22 +254,44 @@ - (void)cleanUp
254 254
 	[self setUseSafeDealloc:NO];
255 255
 	[self unlinkAllReferences];
256 256
 	JSGarbageCollect(ctx);
257  
-
  257
+    
258 258
 	controllerCount--;
259 259
 	if (controllerCount == 0)
260 260
 	{
261  
-		if (OSXObjectClass)		JSClassRelease(OSXObjectClass);
262  
-		if (jsCocoaObjectClass)	JSClassRelease(jsCocoaObjectClass);
263  
-		if (hashObjectClass)	JSClassRelease(hashObjectClass);
264  
-
  261
+		if (OSXObjectClass) {
  262
+            JSClassRelease(OSXObjectClass);
  263
+            OSXObjectClass = nil;
  264
+        }
  265
+        
  266
+		if (jsCocoaObjectClass) {
  267
+            JSClassRelease(jsCocoaObjectClass);
  268
+            jsCocoaObjectClass = nil;
  269
+        }
  270
+        
  271
+		if (hashObjectClass) {
  272
+            JSClassRelease(hashObjectClass);
  273
+            hashObjectClass = nil;
  274
+        }
  275
+        
  276
+        // we need to nil these all out, since they are static
  277
+        // and if we make another JSCocoaController after this- they will
  278
+        // still be around and that's kinda bad (like crashing bad).
265 279
 		[sharedInstanceStats release];
  280
+        sharedInstanceStats = nil;
266 281
 		[closureHash release];
  282
+        closureHash = nil;
267 283
 		[jsFunctionSelectors release];
  284
+        jsFunctionSelectors = nil;
268 285
 		[jsFunctionClasses release];
  286
+        jsFunctionClasses = nil;
269 287
 		[jsFunctionHash release];
  288
+        jsFunctionHash = nil;
270 289
 		[splitCallCache release];
  290
+        splitCallCache = nil;
271 291
 		[jsClassParents release];
  292
+        jsClassParents = nil;
272 293
 		[boxedObjects release];
  294
+        boxedObjects = nil;
273 295
 	}
274 296
 
275 297
 	JSGlobalContextRelease(ctx);
2  Multiple JSCocoa instances/Multiple JSCocoa instances.xcodeproj/project.pbxproj
@@ -327,7 +327,7 @@
327 327
 		C05733CC08A9546B00998B17 /* Debug */ = {
328 328
 			isa = XCBuildConfiguration;
329 329
 			buildSettings = {
330  
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
  330
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
331 331
 				GCC_C_LANGUAGE_STANDARD = c99;
332 332
 				GCC_OPTIMIZATION_LEVEL = 0;
333 333
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
1  Multiple JSCocoa instances/classCode.js
@@ -12,6 +12,7 @@
12 12
 		Method('add:and:').encoding('int int int').fn = function(a, b)
13 13
 		{
14 14
 			log('Objc class method adding ' + a + ' and ' + b)
  15
+            log(NSMakeRect(1, 1, 1, 1));
15 16
 			return a+b+magic
16 17
 		}
17 18
 	}

0 notes on commit 8cb14d5

Please sign in to comment.
Something went wrong with that request. Please try again.