Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-14292] (3_1_X) Avoid race condition on view detach #4536

Merged
merged 1 commit into from
Aug 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions iphone/Classes/TiUITableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@
NSInteger frameChanges;
TiViewProxy* headerViewProxy;
TiViewProxy* footerViewProxy;
BOOL viewWillDetach;
}

@property (nonatomic, assign) BOOL viewWillDetach;

#pragma mark Framework
-(CGFloat)tableRowHeight:(CGFloat)height;
-(NSInteger)indexForRow:(TiUITableViewRowProxy*)row;
Expand Down
16 changes: 14 additions & 2 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ -(void) setSelectedBackgroundGradient_:(TiGradient *)newGradient

@implementation TiUITableView
#pragma mark Internal
@synthesize searchString;
@synthesize searchString, viewWillDetach;

-(id)init
{
Expand Down Expand Up @@ -1260,7 +1260,11 @@ -(CGFloat)contentHeightForWidth:(CGFloat)suggestedWidth

-(void)hideSearchScreen:(id)sender
{
// check to make sure we're not in the middle of a layout, in which case we
if (viewWillDetach) {
return;
}

// check to make sure we're not in the middle of a layout, in which case we
// want to try later or we'll get weird drawing animation issues
if (tableview.frame.size.width==0)
{
Expand Down Expand Up @@ -1290,6 +1294,10 @@ -(void)hideSearchScreen:(id)sender
// because of where the hide might be triggered from.


if (viewWillDetach) {
return;
}
searchActivated = NO;
NSArray* visibleRows = [tableview indexPathsForVisibleRows];
[tableview reloadRowsAtIndexPaths:visibleRows withRowAnimation:UITableViewRowAnimationNone];

Expand Down Expand Up @@ -2428,6 +2436,10 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

- (void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
if (viewWillDetach) {
return;
}

animateHide = YES;
[self performSelector:@selector(hideSearchScreen:) withObject:nil afterDelay:0.2];
}
Expand Down
4 changes: 3 additions & 1 deletion iphone/Classes/TiUITableViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ -(TiUITableView*)tableView

-(void)viewWillDetach
{
((TiUITableView*)[self view]).viewWillDetach = YES;
for (TiUITableViewSectionProxy* section in sections) {
for (TiUITableViewRowProxy* row in [section rows]) {
[row detachView];
Expand All @@ -77,7 +78,8 @@ -(void)viewWillDetach

-(void)viewDidAttach
{
TiUITableView * ourView = (TiUITableView *)[self view];
TiUITableView * ourView = (TiUITableView *)[self view];
ourView.viewWillDetach = NO;
for (TiUITableViewSectionProxy* section in sections) {
[section setTable:ourView];
}
Expand Down