Fixed: Infinite loop when a first responder has a nil superview

This bug appears only if a table view have been added to the window.

CPTableView observes first responder changes and moves up in the view
hierarchy to determine the edited data view. If for some reason, a
superview in the hierarchy was nil, we entered an infinite loop.

This commit adds guards to the recursive method that searches the data
view. Also added an early return when the fr changes to a view outside
the table.

Fixes #1875
This commit is contained in:
cacaodev committed 2013-03-24 18:37:12 +01:00
1 parent afc2c17b5a
commit 3ef5cfe846
1 file changed
+11 -3
+11 -3
View File
@@ -1981,11 +1981,12 @@ NOT YET IMPLEMENTED
return -1;
var cellView = aView,
contentView = [[self window] contentView];
contentView = [[self window] contentView],
max_rec = 100;
while (1)
while (max_rec--)
{
if (cellView == contentView)
if (!cellView || cellView === contentView)
{
return -1;
}
@@ -5048,6 +5049,13 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
{
var responder = [[self window] firstResponder];
if (!responder || ![responder isDescendantOf:self])
{
_editingRow = CPNotFound;
_editingColumn = CPNotFound;
return;
}
_editingRow = [self rowForView:responder];
_editingColumn = [self columnForView:responder];