Skip to content

Commit

Permalink
Removed super selector leak when calling a swizzled method
Browse files Browse the repository at this point in the history
  • Loading branch information
parmanoir committed Aug 3, 2011
1 parent 0c45a77 commit 2541dfa
Show file tree
Hide file tree
Showing 60 changed files with 10,611 additions and 6,641 deletions.
6 changes: 5 additions & 1 deletion JSCocoa/JSCocoaController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4769,7 +4769,11 @@ static JSValueRef jsCocoaObject_callAsFunction(JSContextRef ctx, JSObjectRef fun
JSStringRef resultStringJS = JSValueToStringCopy(ctx, arguments[1], NULL); JSStringRef resultStringJS = JSValueToStringCopy(ctx, arguments[1], NULL);
superSelector = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS); superSelector = (NSString*)JSStringCopyCFString(kCFAllocatorDefault, resultStringJS);
JSStringRelease(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 // Swizzled handling : we're just changing the selector
Expand Down
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.
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.
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.
1 change: 1 addition & 0 deletions TestsRunner/ApplicationController.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@


NSError* testNSError; NSError* testNSError;


BOOL areTestsRunning;
BOOL runningContinuously; BOOL runningContinuously;
// If we cycle context each time, we can test bindings each time. // If we cycle context each time, we can test bindings each time.
BOOL cyclingContext; BOOL cyclingContext;
Expand Down
24 changes: 19 additions & 5 deletions TestsRunner/ApplicationController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (id)init {
return nil; return nil;


test_unit = test_delegate = test_webview = test_autocall = YES; test_unit = test_delegate = test_webview = test_autocall = YES;

areTestsRunning = NO;
return self; return self;
} }


Expand Down Expand Up @@ -98,8 +98,7 @@ - (void)cycleContext
// //
int runCount = 0; int runCount = 0;


- (IBAction)runJSTests:(id)sender - (IBAction)_runJSTests:(id)sender {
{
[self cycleContext]; [self cycleContext];


[textField setStringValue:@"Running Tests ..."]; [textField setStringValue:@"Running Tests ..."];
Expand Down Expand Up @@ -241,7 +240,14 @@ - (IBAction)runJSTests:(id)sender
NSLog(@"r=%@", r); NSLog(@"r=%@", r);
*/ */
} }

- (IBAction)runJSTests:(id)sender
{
if (areTestsRunning)
return;
areTestsRunning = YES;
[self _runJSTests:sender];
areTestsRunning = NO;
}


- (IBAction)_runJSTestsContinuously:(id)sender - (IBAction)_runJSTestsContinuously:(id)sender
{ {
Expand All @@ -267,6 +273,15 @@ - (BOOL)validateMenuItem:(NSMenuItem *) menuItem {
return NO; 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");
}
}


// //
// //
Expand Down Expand Up @@ -1165,4 +1180,3 @@ + (void)testFunction:(void (^)(NSError *))theBlock {







5 changes: 3 additions & 2 deletions TestsRunner/English.lproj/MainMenu.xib
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1360,20 +1360,21 @@
<object class="NSTextField" id="835093140"> <object class="NSTextField" id="835093140">
<reference key="NSNextResponder" ref="439893737"/> <reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">290</int> <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="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/> <reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="291550997"> <object class="NSTextFieldCell" key="NSCell" id="291550997">
<int key="NSCellFlags">68288064</int> <int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272892928</int> <int key="NSCellFlags2">272892928</int>
<string key="NSContents">Text field</string> <string key="NSContents"/>
<object class="NSFont" key="NSSupport"> <object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string> <string key="NSName">LucidaGrande</string>
<double key="NSSize">9</double> <double key="NSSize">9</double>
<int key="NSfFlags">3614</int> <int key="NSfFlags">3614</int>
</object> </object>
<string key="NSPlaceholderString">…</string>
<reference key="NSControlView" ref="835093140"/> <reference key="NSControlView" ref="835093140"/>
<object class="NSColor" key="NSBackgroundColor" id="895343154"> <object class="NSColor" key="NSBackgroundColor" id="895343154">
<int key="NSColorSpace">6</int> <int key="NSColorSpace">6</int>
Expand Down
Loading

0 comments on commit 2541dfa

Please sign in to comment.