Skip to content

Commit

Permalink
[DEV] Hand-merge with @simX since git refuses.
Browse files Browse the repository at this point in the history
  • Loading branch information
rentzsch committed Jul 16, 2009
1 parent 62b300b commit b4eb42b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
2 changes: 2 additions & 0 deletions ClickToFlash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@
A494CC2B0F9F2446007D5EEB /* ctf.icns */,
D9566C2B0F37EA0800358646 /* deSIFR Resources */,
);
indentWidth = 4;
name = Plugin;
sourceTree = "<group>";
tabWidth = 4;
};
55EB70550E04A8A40016593D /* Frameworks */ = {
isa = PBXGroup;
Expand Down
15 changes: 12 additions & 3 deletions Plugin/CTFURLConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ - (NSHTTPURLResponse *)getURLResponseHeaders:(NSURL *)URL
[NSThread detachNewThreadSelector:@selector(startRequest:) toTarget:self withObject:request];
[request release];

[theLock lockWhenCondition:1 beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];
[theLock lockWhenCondition:1];
[theLock unlock];
if (error) (*error) = errorToReturn;

return [responseToReturn autorelease];
Expand All @@ -67,12 +68,20 @@ - (void)startRequest:(NSURLRequest *)request;
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self
startImmediately:YES];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];

NSRunLoop *rl = [NSRunLoop currentRunLoop];

while ([rl runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) {
if ([theLock tryLockWhenCondition:1]) {
[theLock unlock];
break;
}
}

[connection release];

[request release];
[pool drain];

}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
Expand Down
39 changes: 24 additions & 15 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -401,26 +401,35 @@ - (id) initWithArguments:(NSDictionary *)arguments
return self;
}

- (void) dealloc
- (void)webPlugInDestroy
{
[self _removeTrackingAreaForCTF];
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[self _removeTrackingAreaForCTF];
[NSObject cancelPreviousPerformRequestsWithTarget:self];

[self _abortAlert]; // to be on the safe side

// notify that this ClickToFlash plugin is going away
[[CTFMenubarMenuController sharedController] unregisterView: self];

[self setContainer:nil];
[self setHost:nil];
[self setWebView:nil];
[self setBaseURL:nil];
[self setAttributes:nil];

[_flashVars release];
[_badgeText release];

[[NSNotificationCenter defaultCenter] removeObserver: self];
[[CTFMenubarMenuController sharedController] unregisterView:self];

[self setContainer:nil];
[self setHost:nil];
[self setWebView:nil];
[self setBaseURL:nil];
[self setAttributes:nil];

[_flashVars release];
_flashVars = nil;
[_badgeText release];
_badgeText = nil;

[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void) dealloc
{
// Just in case...
[self webPlugInDestroy];

#if LOGGING_ENABLED
NSLog(@"ClickToFlash:\tdealloc");
#endif
Expand Down

0 comments on commit b4eb42b

Please sign in to comment.