From ca06bb0edc752c6a55d51450af8a4bb4acf3b5f5 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 17 Jun 2009 21:57:49 +0000 Subject: [PATCH] Epic multi-threading. --- Cydia.mm | 15 ++++++++++----- UICaboodle/RVBook.mm | 3 +++ UICaboodle/RVPage.h | 1 + UICaboodle/RVPage.mm | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cydia.mm b/Cydia.mm index f90aa0bb..879ba998 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -2178,6 +2178,7 @@ struct PackageNameOrdering : } + (Package *) packageWithIterator:(pkgCache::PkgIterator)iterator withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database { +@synchronized ([Database class]) { pkgCache::VerIterator version; _profile(Package$packageWithIterator$GetCandidateVer) @@ -2193,7 +2194,7 @@ struct PackageNameOrdering : inPool:pool database:database ] autorelease]; -} +} } - (pkgCache::PkgIterator) iterator { return iterator_; @@ -2981,11 +2982,12 @@ static NSArray *Finishes_; } - (Package *) packageWithName:(NSString *)name { +@synchronized ([Database class]) { if (static_cast(cache_) == NULL) return nil; pkgCache::PkgIterator iterator(cache_->FindPkg([name UTF8String])); return iterator.end() ? nil : [Package packageWithIterator:iterator withZone:NULL inPool:pool_ database:self]; -} +} } - (Database *) init { if ((self = [super init]) != nil) { @@ -3141,6 +3143,8 @@ static NSArray *Finishes_; } - (void) reloadData { _pooled +@synchronized ([Database class]) { + @synchronized (self) { ++era_; } @@ -3279,7 +3283,7 @@ static NSArray *Finishes_; _trace(); } -} +} } - (void) configure { NSString *dpkg = [NSString stringWithFormat:@"dpkg --configure -a --status-fd %u", statusfd_]; @@ -6566,9 +6570,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { section = [filtered_ objectAtIndex:(row - 1)]; name = [section name]; - if (name != nil) + if (name != nil) { + name = [NSString stringWithString:name]; title = [[NSBundle mainBundle] localizedStringForKey:Simplify(name) value:nil table:@"Sections"]; - else { + } else { name = @""; title = UCLocalize("NO_SECTION"); } diff --git a/UICaboodle/RVBook.mm b/UICaboodle/RVBook.mm index 433de39d..18de2b6d 100644 --- a/UICaboodle/RVBook.mm +++ b/UICaboodle/RVBook.mm @@ -65,6 +65,9 @@ if (toolbar_ != nil) [toolbar_ setDelegate:nil]; + for (RVPage *page in pages_) + [page setBook:nil]; + [pages_ release]; [navbar_ release]; [transition_ release]; diff --git a/UICaboodle/RVPage.h b/UICaboodle/RVPage.h index 7aebba2d..18e3dd4c 100644 --- a/UICaboodle/RVPage.h +++ b/UICaboodle/RVPage.h @@ -35,5 +35,6 @@ - (id) initWithBook:(RVBook *)book; - (void) setDelegate:(id)delegate; +- (void) setBook:(RVBook *)book; @end diff --git a/UICaboodle/RVPage.mm b/UICaboodle/RVPage.mm index 77007558..9d77a861 100644 --- a/UICaboodle/RVPage.mm +++ b/UICaboodle/RVPage.mm @@ -76,4 +76,8 @@ delegate_ = delegate; } +- (void) setBook:(RVBook *)book { + book_ = book; +} + @end -- 2.45.2