From e2580bda05da1c0e0c40298c309bbd5e76bae1ea Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Wed, 6 Mar 2013 10:30:54 -0500 Subject: [PATCH] Fixed: objj_backtrace_print is not available in release frameworks objj_backtrace_print is only available in debug frameworks. Previously we were not ensuring that objj_backtrace_print was available, which caused an error when running with release frameworks. Now objj_backtrace_print is checked for availability. --- Foundation/CPDictionary.j | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index 70c1e82bc..5f930e955 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -272,8 +272,11 @@ var CPDictionaryShowNilDeprecationMessage = YES; { CPDictionaryShowNilDeprecationMessage = NO; CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil object from objects[%d]", [self className], _cmd, i]); - objj_backtrace_print(CPLog.warn); - // FIXME: After release of 0.9.7 change 3 lines above to this: + + if (typeof(objj_backtrace_print) === "function") + objj_backtrace_print(CPLog.warn); + + // FIXME: After release of 0.9.7 change this block to: // [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + i + @"]"]; } @@ -281,8 +284,11 @@ var CPDictionaryShowNilDeprecationMessage = YES; { CPDictionaryShowNilDeprecationMessage = NO; CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil key from keys[%d]", [self className], _cmd, i]); - objj_backtrace_print(CPLog.warn); - // FIXME: After release of 0.9.7 change 3 lines above to this: + + if (typeof(objj_backtrace_print) === "function") + objj_backtrace_print(CPLog.warn); + + // FIXME: After release of 0.9.7 change this block to: // [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil key from keys[" + i + @"]"]; } @@ -330,7 +336,10 @@ var CPDictionaryShowNilDeprecationMessage = YES; { CPDictionaryShowNilDeprecationMessage = NO; CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil object from objects[%d]", [self className], _cmd, (index / 2) - 1]); - objj_backtrace_print(CPLog.warn); + + if (typeof(objj_backtrace_print) === "function") + objj_backtrace_print(CPLog.warn); + // FIXME: After release of 0.9.7 change 3 lines above to this: // [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + ((index / 2) - 1) + @"]"]; } @@ -339,7 +348,10 @@ var CPDictionaryShowNilDeprecationMessage = YES; { CPDictionaryShowNilDeprecationMessage = NO; CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: Attempt to insert nil key from keys[%d]", [self className], _cmd, (index / 2) - 1]); - objj_backtrace_print(CPLog.warn); + + if (typeof(objj_backtrace_print) === "function") + objj_backtrace_print(CPLog.warn); + // FIXME: After release of 0.9.7 change 3 lines above to this: // [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil key from keys[" + ((index / 2) - 1) + @"]"]; } @@ -659,16 +671,22 @@ var CPDictionaryShowNilDeprecationMessage = YES; if (aKey === nil) { CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: key cannot be nil", [self className], _cmd]); - objj_backtrace_print(CPLog.warn); - // FIXME: After release of 0.9.7 change 2 lines above to this: + + if (typeof(objj_backtrace_print) === "function") + objj_backtrace_print(CPLog.warn); + + // FIXME: After release of 0.9.7 change this block to: // [CPException raise:CPInvalidArgumentException reason:@"key cannot be nil"]; } if (anObject === nil) { CPLog.warn([CPString stringWithFormat:@"[%s %s] DEPRECATED: object cannot be nil (key: %s)", [self className], _cmd, aKey]); - objj_backtrace_print(CPLog.warn); - // FIXME: After release of 0.9.7 change 2 lines above to this: + + if (typeof(objj_backtrace_print) === "function") + objj_backtrace_print(CPLog.warn); + + // FIXME: After release of 0.9.7 change this block to: // [CPException raise:CPInvalidArgumentException reason:@"object cannot be nil (key: " + aKey + @")"]; } }