diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-02 00:43:49 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-02 00:51:45 -0800 |
commit | 0175295c662c74feeb0d5056b0fa27a6b0c42302 (patch) | |
tree | 2bfb7b9652dd3aef856261aeb145c453507ad9f7 | |
parent | 8d603a7de7b0e5e8f72eabe6b2307c4dfff5b663 (diff) |
Improve era locking on tables to allow rotation with HUDs.
-rw-r--r-- | MobileCydia.mm | 22 |
1 files 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_); |