X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/1b18f0262a9662e5d666523ca70bd8df220e28b6..23ea638cc495a04f9926f37817beffdd9caa0341:/MobileCydia.mm?ds=inline diff --git a/MobileCydia.mm b/MobileCydia.mm index c4abc53d..642c9e12 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1808,8 +1808,6 @@ typedef std::map< unsigned long, _H > SourceMap; - (uint32_t) compareBySection:(NSArray *)sections; -- (uint32_t) compareForChanges; - - (void) install; - (void) remove; @@ -2250,16 +2248,22 @@ struct PackageNameOrdering : } - (Address *) maintainer { - if (file_.end()) +@synchronized (database_) { + if ([database_ era] != era_ || file_.end()) return nil; + pkgRecords::Parser *parser = &[database_ records]->Lookup(file_); const std::string &maintainer(parser->Maintainer()); return maintainer.empty() ? nil : [Address addressWithString:[NSString stringWithUTF8String:maintainer.c_str()]]; -} +} } - (size_t) size { - return version_.end() ? 0 : version_->InstalledSize; -} +@synchronized (database_) { + if ([database_ era] != era_ || version_.end()) + return 0; + + return version_->InstalledSize; +} } - (NSString *) longDescription { @synchronized (database_) { @@ -2449,7 +2453,7 @@ struct PackageNameOrdering : icon = [UIImage imageAtPath:[static_cast(icon_) substringFromIndex:7]]; if (icon == nil) if (section != nil) icon = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]]; - if (icon == nil) if (source_ != nil) if (NSString *dicon = [source_ defaultIcon]) + if (icon == nil) if (Source *source = [self source]) if (NSString *dicon = [source defaultIcon]) if ([dicon hasPrefix:@"file:///"]) // XXX: correct escaping icon = [UIImage imageAtPath:[dicon substringFromIndex:7]]; @@ -2679,33 +2683,6 @@ struct PackageNameOrdering : return _not(uint32_t); } -- (uint32_t) compareForChanges { - union { - uint32_t key; - - struct { - uint32_t timestamp : 30; - uint32_t ignored : 1; - uint32_t upgradable : 1; - } bits; - } value; - - bool upgradable([self upgradableAndEssential:YES]); - value.bits.upgradable = upgradable ? 1 : 0; - - if (upgradable) { - value.bits.timestamp = 0; - value.bits.ignored = [self ignored] ? 0 : 1; - value.bits.upgradable = 1; - } else { - value.bits.timestamp = static_cast([[self seen] timeIntervalSince1970]) >> 2; - value.bits.ignored = 0; - value.bits.upgradable = 0; - } - - return _not(uint32_t) - value.key; -} - - (void) clear { @synchronized (database_) { pkgProblemResolver *resolver = [database_ resolver]; @@ -2936,12 +2913,17 @@ static NSString *Warning_; return era_; } +- (void) releasePackages { + CFArrayApplyFunction(packages_, CFRangeMake(0, CFArrayGetCount(packages_)), reinterpret_cast(&CFRelease), NULL); + CFArrayRemoveAllValues(packages_); +} + - (void) dealloc { // XXX: actually implement this thing _assert(false); - NSRecycleZone(zone_); - // XXX: malloc_destroy_zone(zone_); + [self releasePackages]; apr_pool_destroy(pool_); + NSRecycleZone(zone_); [super dealloc]; } @@ -3229,9 +3211,7 @@ static NSString *Warning_; @synchronized (self) { ++era_; - CFArrayApplyFunction(packages_, CFRangeMake(0, CFArrayGetCount(packages_)), reinterpret_cast(&CFRelease), NULL); - CFArrayRemoveAllValues(packages_); - + [self releasePackages]; sources_.clear(); _error->Discard(); @@ -3697,7 +3677,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (NSArray *) getInstalledPackages { NSArray *packages([[Database sharedInstance] packages]); - NSMutableArray *installed([NSMutableArray arrayWithCapacity:[packages count]]); + NSMutableArray *installed([NSMutableArray arrayWithCapacity:1024]); for (Package *package in packages) if ([package installed] != nil) [installed addObject:package]; @@ -7912,9 +7892,8 @@ typedef enum { Database *database_; int tag_; - - UIKeyboard *keyboard_; int huds_; + NSURL *starturl_; SectionsController *sections_; ChangesController *changes_; @@ -8586,12 +8565,7 @@ static _finline void _setHomePage(Cydia *self) { - (void) applicationOpenURL:(NSURL *)url { [super applicationOpenURL:url]; - int tag; - if (CYViewController *page = [self pageForURL:url hasTag:&tag]) { - [self setPage:page]; - tag_ = tag; - [tabbar_ setSelectedViewController:(tag_ == -1 ? nil : [[tabbar_ viewControllers] objectAtIndex:tag_])]; - } + starturl_ = [url retain]; } - (void) applicationWillResignActive:(UIApplication *)application { @@ -8772,9 +8746,19 @@ _trace(); [self reloadData]; PrintTimes(); - // Show the home page - [tabbar_ setSelectedIndex:0]; - _setHomePage(self); + // Show the initial page + CYViewController *page = nil; + int tag = 0; + if (starturl_ != nil && (page = [self pageForURL:starturl_ hasTag:&tag])) { + [starturl_ release]; + [self setPage:page]; + tag_ = tag; + [tabbar_ setSelectedViewController:(tag_ == -1 ? nil : [[tabbar_ viewControllers] objectAtIndex:tag_])]; + } else { + [tabbar_ setSelectedIndex:0]; + _setHomePage(self); + } + [window_ setUserInteractionEnabled:YES]; // XXX: does this actually slow anything down?