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

fix(ios): check for selector availability #12128

Merged
merged 6 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 12 additions & 6 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ - (void)add:(id)arg

if (windowOpened) {
// Turn on clipping because I have children
[[self view] updateClipping];
if ([[self view] respondsToSelector:@selector(updateClipping)]) {
[[self view] updateClipping];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this does not fix the real issue. Primarily, because this used to work before and the error suggests that a wrong instance is bubbled up in the event

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vijaysingh-axway I think Hans is right here. I did a quick debug session and it appears that self.view is holding a wrong value. Xcode debugger says it's nil so it may have been accidentally released and now holds an invalid pointer. Can you please double check what's going on?

[self contentsWillChange];

if (parentVisible && !hidden) {
Expand Down Expand Up @@ -416,7 +418,9 @@ - (void)animate:(id)arg
}
[self windowWillOpen]; // we need to manually attach the window if you're animating
[parent layoutChildrenIfNeeded];
[[self view] animate:newAnimation];
if ([[self view] respondsToSelector:@selector(animate:)]) {
[[self view] animate:newAnimation];
}
},
NO);
}
Expand Down Expand Up @@ -1632,7 +1636,9 @@ - (void)didReceiveMemoryWarning:(NSNotification *)notification
- (void)animationCompleted:(TiAnimation *)animation
{
[self forgetProxy:animation];
[[self view] animationCompleted];
if ([[self view] respondsToSelector:@selector(animationCompleted)]) {
[[self view] animationCompleted];
}
//Let us add ourselves to the queue to cleanup layout
OSAtomicTestAndClearBarrier(TiRefreshViewEnqueued, &dirtyflags);
[self willEnqueue];
Expand Down Expand Up @@ -2788,7 +2794,7 @@ - (TiDimension)defaultAutoHeightBehavior:(id)unused
- (void)setAccessibilityLabel:(id)accessibilityLabel
{
ENSURE_UI_THREAD(setAccessibilityLabel, accessibilityLabel);
if ([self viewAttached]) {
if ([self viewAttached] && [[self view] respondsToSelector:@selector(setAccessibilityLabel_:)]) {
[[self view] setAccessibilityLabel_:accessibilityLabel];
}
[self replaceValue:accessibilityLabel forKey:@"accessibilityLabel" notification:NO];
Expand All @@ -2797,7 +2803,7 @@ - (void)setAccessibilityLabel:(id)accessibilityLabel
- (void)setAccessibilityValue:(id)accessibilityValue
{
ENSURE_UI_THREAD(setAccessibilityValue, accessibilityValue);
if ([self viewAttached]) {
if ([self viewAttached] && [[self view] respondsToSelector:@selector(setAccessibilityValue_:)]) {
[[self view] setAccessibilityValue_:accessibilityValue];
}
[self replaceValue:accessibilityValue forKey:@"accessibilityValue" notification:NO];
Expand All @@ -2806,7 +2812,7 @@ - (void)setAccessibilityValue:(id)accessibilityValue
- (void)setAccessibilityHint:(id)accessibilityHint
{
ENSURE_UI_THREAD(setAccessibilityHint, accessibilityHint);
if ([self viewAttached]) {
if ([self viewAttached] && [[self view] respondsToSelector:@selector(setAccessibilityHint_:)]) {
[[self view] setAccessibilityHint_:accessibilityHint];
}
[self replaceValue:accessibilityHint forKey:@"accessibilityHint" notification:NO];
Expand Down
25 changes: 25 additions & 0 deletions tests/Resources/ti.ui.tableview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1443,4 +1443,29 @@ describe('Titanium.UI.TableView', function () {
});
win.open();
});

it('TIMOB-28148 : adding view on row causing crash', function (finish) {
var row = Ti.UI.createTableViewRow({ title: 'click me' });
var tableView = Ti.UI.createTableView({
data: [ row ]
});

win = Ti.UI.createWindow({
backgroundColor: 'blue'
});
win.addEventListener('focus', function () {
setTimeout(function () {
try {
const label = Ti.UI.createLabel({ text: 'REQUIRED' });
row.add(label);
finish();
} catch (err) {
return finish(err);
}
}, 2000);
});

win.add(tableView);
win.open();
});
});