Permalink
Browse files

Removed super selector leak when calling a swizzled method

  • Loading branch information...
1 parent 0c45a77 commit 2541dfa9296ecd69395b7f979582b51a6209cbea @parmanoir committed Aug 3, 2011
Showing with 10,611 additions and 6,641 deletions.
  1. +5 −1 JSCocoa/JSCocoaController.m
  2. 0 Tests/{ → ! stock}/1 C and ObjC calls.js
  3. 0 Tests/{ → ! stock}/10 shorthand overload.js
  4. 0 Tests/{ → ! stock}/11 retain test 2.js
  5. 0 Tests/{ → ! stock}/12 instance variables.js
  6. 0 Tests/{ → ! stock}/13 instance.js
  7. 0 Tests/{ → ! stock}/14 class.js
  8. 0 Tests/{ → ! stock}/15 IBOutlet IBAction.js
  9. 0 Tests/{ → ! stock}/16 NSArray NSDictionary easy access.js
  10. 0 Tests/{ → ! stock}/17 struct instance.js
  11. 0 Tests/{ → ! stock}/18 structure args.js
  12. 0 Tests/{ → ! stock}/19 pure js methods.js
  13. 0 Tests/{ → ! stock}/2 structure arguments.js
  14. 0 Tests/{ → ! stock}/20 pointer to function.js
  15. 0 Tests/{ → ! stock}/21 new class definition.js
  16. 0 Tests/{ → ! stock}/22 instance valueOf.js
  17. 0 Tests/{ → ! stock}/23 NSString bridging.js
  18. 0 Tests/{ → ! stock}/24 structure set.js
  19. 0 Tests/{ → ! stock}/25 variadic.js
  20. 0 Tests/{ → ! stock}/26 full NSArray bridge.js
  21. 0 Tests/{ → ! stock}/27 type modifier o.js
  22. 0 Tests/{ → ! stock}/28 struct description.js
  23. 0 Tests/{ → ! stock}/29 pointer handling.js
  24. 0 Tests/{ → ! stock}/3 derivation.js
  25. 0 Tests/{ → ! stock}/30 obj1 == obj2.js
  26. 0 Tests/{ → ! stock}/31 bridgeSupport bench.js
  27. 0 Tests/{ → ! stock}/32 new class syntax.js
  28. 0 Tests/{ → ! stock}/33 class syntax swizzle.js
  29. 0 Tests/{ → ! stock}/34 object keys.js
  30. 0 Tests/{ → ! stock}/35 webview.js
  31. 0 Tests/{ → ! stock}/36 safe dealloc.js
  32. 0 Tests/{ → ! stock}/37 init from webview.js
  33. 0 Tests/{ → ! stock}/38 class walker.js
  34. 0 Tests/{ → ! stock}/39 NSArray js functions.js
  35. 0 Tests/{ → ! stock}/4 js load.js
  36. 0 Tests/{ → ! stock}/40 ObjJ syntax.js
  37. 0 Tests/{ → ! stock}/41 class inner js functions.js
  38. 0 Tests/{ → ! stock}/42 return if.js
  39. 0 Tests/{ → ! stock}/43 @ string and selector.js
  40. 0 Tests/{ → ! stock}/44 instanceWith.js
  41. 0 Tests/{ → ! stock}/45 ƒ function shortcut.js
  42. 0 Tests/{ → ! stock}/46 exceptions.js
  43. 0 Tests/{ → ! stock}/48 ObjJ syntax compatibility.js
  44. 0 Tests/{ → ! stock}/49 out pointer.js
  45. 0 Tests/{ → ! stock}/50 setValueForKey op.js
  46. 0 Tests/{ → ! stock}/51 ObjC blocks.js
  47. 0 Tests/{ → ! stock}/52 line and sourceURL.js
  48. 0 Tests/{ → ! stock}/53 Unicode ObjC classes.js
  49. 0 Tests/{ → ! stock}/54 custom indexed access.js
  50. 0 Tests/{ → ! stock}/55 javascript method override.js
  51. 0 Tests/{ → ! stock}/56 whitespace.js
  52. 0 Tests/{ → ! stock}/6 basic arguments.js
  53. 0 Tests/{ → ! stock}/7 split call.js
  54. 0 Tests/{ → ! stock}/8 zero arg autocall.js
  55. 0 Tests/{ → ! stock}/9 auto setter.js
  56. +1 −0 TestsRunner/ApplicationController.h
  57. +19 −5 TestsRunner/ApplicationController.m
  58. +3 −2 TestsRunner/English.lproj/MainMenu.xib
  59. +10,567 −6,633 ...tsRunner.xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate
  60. +16 −0 TestsRunner/TestsRunner.xcodeproj/xcuserdata/mini.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
@@ -4769,7 +4769,11 @@ static JSValueRef jsCocoaObject_callAsFunction(JSContextRef ctx, JSObjectRef fun
JSStringRef resultStringJS = JSValueToStringCopy(ctx, arguments[1], NULL);
superSelector = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS);
JSStringRelease(resultStringJS);
- if (callingSwizzled) superSelector = [NSString stringWithFormat:@"%@%@", OriginalMethodPrefix, superSelector];
+ if (callingSwizzled) {
+ NSString* previousSelector = superSelector;
+ superSelector = [NSString stringWithFormat:@"%@%@", OriginalMethodPrefix, superSelector];
+ [previousSelector release];
+ }
}
// Swizzled handling : we're just changing the selector
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -29,6 +29,7 @@
NSError* testNSError;
+ BOOL areTestsRunning;
BOOL runningContinuously;
// If we cycle context each time, we can test bindings each time.
BOOL cyclingContext;
@@ -22,7 +22,7 @@ - (id)init {
return nil;
test_unit = test_delegate = test_webview = test_autocall = YES;
-
+ areTestsRunning = NO;
return self;
}
@@ -98,8 +98,7 @@ - (void)cycleContext
//
int runCount = 0;
-- (IBAction)runJSTests:(id)sender
-{
+- (IBAction)_runJSTests:(id)sender {
[self cycleContext];
[textField setStringValue:@"Running Tests ..."];
@@ -241,7 +240,14 @@ - (IBAction)runJSTests:(id)sender
NSLog(@"r=%@", r);
*/
}
-
+- (IBAction)runJSTests:(id)sender
+{
+ if (areTestsRunning)
+ return;
+ areTestsRunning = YES;
+ [self _runJSTests:sender];
+ areTestsRunning = NO;
+}
- (IBAction)_runJSTestsContinuously:(id)sender
{
@@ -267,6 +273,15 @@ - (BOOL)validateMenuItem:(NSMenuItem *) menuItem {
return NO;
}
+- (void)dumpObjectAtAddress:(NSUInteger)address {
+ void* p = (void*)address;
+ NSLog(@"object at %p=", p);
+ @try {
+ NSLog(@"%@", *(id*)p);
+ } @catch (NSException* e) {
+ NSLog(@"Bad address");
+ }
+}
//
//
@@ -1165,4 +1180,3 @@ + (void)testFunction:(void (^)(NSError *))theBlock {
-
@@ -1360,20 +1360,21 @@
<object class="NSTextField" id="835093140">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{17, 20}, {386, 11}}</string>
+ <string key="NSFrame">{{17, 19}, {386, 12}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="291550997">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272892928</int>
- <string key="NSContents">Text field</string>
+ <string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">9</double>
<int key="NSfFlags">3614</int>
</object>
+ <string key="NSPlaceholderString">…</string>
<reference key="NSControlView" ref="835093140"/>
<object class="NSColor" key="NSBackgroundColor" id="895343154">
<int key="NSColorSpace">6</int>
Oops, something went wrong.

0 comments on commit 2541dfa

Please sign in to comment.