ManageView *manage_;
SearchView *search_;
- PackageView *package_;
+ NSMutableArray *details_;
}
@end
}
- (void) setPackageView:(PackageView *)view {
- if (package_ == nil)
- package_ = [view retain];
+ WebThreadLock();
+ [view setPackage:nil];
+ if ([details_ count] < 3)
+ [details_ addObject:view];
+ WebThreadUnlock();
+}
+
+- (PackageView *) _packageView {
+ return [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];
}
- (PackageView *) packageView {
PackageView *view;
+ size_t count([details_ count]);
- if (package_ == nil)
- view = [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];
- else {
- return package_;
- view = [package_ autorelease];
- package_ = nil;
+ if (count == 0) {
+ view = [self _packageView];
+ renew:
+ [details_ addObject:[self _packageView]];
+ } else {
+ view = [[[details_ lastObject] retain] autorelease];
+ [details_ removeLastObject];
+ if (count == 1)
+ goto renew;
}
return view;
withClass:[ManageView class]
] retain];
- [self setPackageView:[self packageView]];
+ details_ = [[NSMutableArray alloc] initWithCapacity:4];
+ [details_ addObject:[self _packageView]];
+ [details_ addObject:[self _packageView]];
PrintTimes();
- (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
if (![self _allowJavaScriptPanel])
return;
-
- // WTR: [self retain];
+ [self retain];
UIActionSheet *sheet = [[[UIActionSheet alloc]
initWithTitle:nil
- (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
if (![self _allowJavaScriptPanel])
return NO;
+ [self retain];
UIActionSheet *sheet = [[[UIActionSheet alloc]
initWithTitle:nil
NSNumber *confirm([confirm_ autorelease]);
confirm_ = nil;
+
+ [self autorelease];
return [confirm boolValue];
}
}
- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
- [loading_ addObject:frame];
+ if ([loading_ count] == 0)
+ [self retain];
+ [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
if ([frame parentFrame] == nil) {
[webview_ resignFirstResponder];
}
- (void) _finishLoading {
- if (reloading_ || [loading_ count] != 0)
+ size_t count([loading_ count]);
+ if (count == 0)
+ [self autorelease];
+ if (reloading_ || count != 0)
return;
if (finish_ != nil)
[self callFunction:finish_];
}
- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
- [loading_ removeObject:frame];
-
+ [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
[self _finishLoading];
if ([frame parentFrame] == nil) {
}
- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
- [loading_ removeObject:frame];
- if (reloading_)
- return;
+ if ([frame parentFrame] == nil)
+ [self autorelease];
+ [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
[self _finishLoading];
+ if (reloading_)
+ return;
+
if ([frame parentFrame] == nil) {
[self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
[[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],