Skip to content

Commit 3b7739e

Browse files
author
Chris Suter
committed
Fixed a few bugs
1 parent 97ec6c1 commit 3b7739e

File tree

3 files changed

+41
-26
lines changed

3 files changed

+41
-26
lines changed

ClickToFlash.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@
232232
A494CC2B0F9F2446007D5EEB /* ctf.icns */,
233233
D9566C2B0F37EA0800358646 /* deSIFR Resources */,
234234
);
235+
indentWidth = 4;
235236
name = Plugin;
236237
sourceTree = "<group>";
238+
tabWidth = 4;
237239
};
238240
55EB70550E04A8A40016593D /* Frameworks */ = {
239241
isa = PBXGroup;

Plugin/CTFURLConnection.m

+15-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ - (NSHTTPURLResponse *)getURLResponseHeaders:(NSURL *)URL
3636
[request release];
3737

3838
[theLock lockWhenCondition:1];
39+
[theLock unlock];
3940
if (error) (*error) = errorToReturn;
41+
4042

4143
return [responseToReturn autorelease];
4244
}
@@ -53,34 +55,37 @@ + (NSHTTPURLResponse *)getURLResponseHeaders:(NSURL *)URL
5355

5456
- (void)startRequest:(NSURLRequest *)request;
5557
{
56-
5758
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
58-
[request retain];
5959

6060
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
6161
delegate:self
6262
startImmediately:YES];
63-
[[NSRunLoop currentRunLoop] run];
63+
64+
NSRunLoop *rl = [NSRunLoop currentRunLoop];
65+
66+
while ([rl runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) {
67+
if ([theLock tryLockWhenCondition:1]) {
68+
[theLock unlock];
69+
break;
70+
}
71+
}
72+
6473
[connection release];
6574

66-
[request release];
6775
[pool drain];
68-
6976
}
7077

7178
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
7279
{
73-
74-
[theLock tryLock];
80+
[theLock lock];
7581

7682
errorToReturn = error;
7783
[theLock unlockWithCondition:1];
7884
}
7985

8086
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)theResponse;
8187
{
82-
83-
[theLock tryLock];
88+
[theLock lock];
8489

8590
// we cancel here, because otherwise NSURLConnection will continue to download
8691
// data due to a bug; even though we made a HEAD request, it still downloads
@@ -93,8 +98,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLRe
9398

9499
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
95100
{
96-
97-
[theLock tryLock];
101+
[theLock lock];
98102

99103
[theLock unlockWithCondition:1];
100104
}

Plugin/Plugin.m

+24-15
Original file line numberDiff line numberDiff line change
@@ -381,26 +381,35 @@ - (id) initWithArguments:(NSDictionary *)arguments
381381
return self;
382382
}
383383

384-
- (void) dealloc
384+
- (void)webPlugInDestroy
385385
{
386-
[self _removeTrackingAreaForCTF];
387-
[NSObject cancelPreviousPerformRequestsWithTarget:self];
386+
[self _removeTrackingAreaForCTF];
387+
[NSObject cancelPreviousPerformRequestsWithTarget:self];
388388

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

391391
// notify that this ClickToFlash plugin is going away
392-
[[CTFMenubarMenuController sharedController] unregisterView: self];
393-
394-
[self setContainer:nil];
395-
[self setHost:nil];
396-
[self setWebView:nil];
397-
[self setBaseURL:nil];
398-
[self setAttributes:nil];
399-
400-
[_flashVars release];
401-
[_badgeText release];
402-
403-
[[NSNotificationCenter defaultCenter] removeObserver: self];
392+
[[CTFMenubarMenuController sharedController] unregisterView:self];
393+
394+
[self setContainer:nil];
395+
[self setHost:nil];
396+
[self setWebView:nil];
397+
[self setBaseURL:nil];
398+
[self setAttributes:nil];
399+
400+
[_flashVars release];
401+
_flashVars = nil;
402+
[_badgeText release];
403+
_badgeText = nil;
404+
405+
[[NSNotificationCenter defaultCenter] removeObserver:self];
406+
}
407+
408+
- (void) dealloc
409+
{
410+
// Just in case...
411+
[self webPlugInDestroy];
412+
404413
#if LOGGING_ENABLED
405414
NSLog(@"ClickToFlash:\tdealloc");
406415
#endif

0 commit comments

Comments
 (0)