From 0175295c662c74feeb0d5056b0fa27a6b0c42302 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 2 Dec 2010 00:43:49 -0800 Subject: Improve era locking on tables to allow rotation with HUDs. --- MobileCydia.mm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index c6ba06d..0803d58 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -5415,6 +5415,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UITableViewDelegate > { _transient Database *database_; + unsigned era_; NSMutableArray *packages_; NSMutableArray *sections_; UITableView *list_; @@ -5472,11 +5473,15 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (Package *) packageAtIndexPath:(NSIndexPath *)path { +@synchronized (database_) { + if ([database_ era] != era_) + return nil; + Section *section([sections_ objectAtIndex:[path section]]); NSInteger row([path row]); Package *package([packages_ objectAtIndex:([section row] + row)]); - return package; -} + return [[package retain] autorelease]; +} } - (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path { PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]); @@ -5541,6 +5546,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) reloadData { + era_ = [database_ era]; NSArray *packages = [database_ packages]; [packages_ removeAllObjects]; @@ -6667,7 +6673,7 @@ freeing the view controllers on tab change */ } - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { - return ![updatedelegate_ hudIsShowing] && (IsWildcat_ || orientation == UIInterfaceOrientationPortrait); + return IsWildcat_ || orientation == UIInterfaceOrientationPortrait; } - (void) setUpdate:(NSDate *)date { @@ -7246,6 +7252,7 @@ freeing the view controllers on tab change */ UITableViewDelegate > { _transient Database *database_; + unsigned era_; CFMutableArrayRef packages_; NSMutableArray *sections_; UITableView *list_; @@ -7303,10 +7310,14 @@ freeing the view controllers on tab change */ } - (Package *) packageAtIndexPath:(NSIndexPath *)path { +@synchronized (database_) { + if ([database_ era] != era_) + return nil; + Section *section([sections_ objectAtIndex:[path section]]); NSInteger row([path row]); - return [self packageAtIndex:([section row] + row)]; -} + return [[[self packageAtIndex:([section row] + row)] retain] autorelease]; +} } - (UITableViewCell *) tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path { PackageCell *cell((PackageCell *) [table dequeueReusableCellWithIdentifier:@"Package"]); @@ -7373,6 +7384,7 @@ freeing the view controllers on tab change */ } - (void) reloadData { + era_ = [database_ era]; NSArray *packages = [database_ packages]; CFArrayRemoveAllValues(packages_); -- cgit v1.2.3