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

Already on GitHub? Sign in to your account

Crash:DTHTMLElement *oneElement in listRoot.childNodes #335

Closed
bolee opened this Issue Mar 11, 2013 · 6 comments

Comments

Projects
None yet
2 participants

bolee commented Mar 11, 2013

some times,in this interface DTHTMLElementLI,app will crash in here:

- (NSUInteger)_indexOfListItemInListRoot:(DTHTMLElement *)listRoot
{
    NSInteger index = -1;
//  for (DTHTMLElement *oneElement in listRoot.childNodes)//Crash!!!
    for (NSObject *oneElement in listRoot.childNodes)//modify by lee 2013-3-11
    {
        if ([oneElement isKindOfClass:[DTHTMLElementLI class]])
        {
            index++;
        }
        if (oneElement == self)
        {
            break;
        }
    }
    return index;
}

I had modified this, is it right?????

Collaborator

odrobnik commented Mar 11, 2013

Please always clarify what is happening and what you are trying to say. Simply posting code in here doesn't help.

Collaborator

odrobnik commented Mar 11, 2013

Your change does not have any effect since isKindOfClass is available for any subclass of NSObject. What is the exception your are seeing?

Are you getting the one about an array being modified while being enumerated?

odrobnik added a commit that referenced this issue Mar 11, 2013

Added synchronized
Without this it might happen that the childNodes are enumerated while being modified potentially causing an exception. #335
Collaborator

odrobnik commented Mar 11, 2013

@bolee Please respond if this was the problem you were seeing. If yes - and the synchronize fixes it - then please close the issue.

bolee commented Mar 12, 2013

thank you for this !!!

@bolee bolee closed this Mar 12, 2013

@ghost ghost assigned odrobnik Mar 23, 2013

@odrobnik odrobnik reopened this Apr 1, 2013

Collaborator

odrobnik commented Apr 1, 2013

@bolee please report from your debugger which code is changing the childNodes list. Try to move the synchronized higher.

odrobnik added a commit that referenced this issue Apr 2, 2013

Collaborator

odrobnik commented Apr 2, 2013

@bolee I found that the getter was missing the synchronized as well, added. Please see if that fixes it.

@odrobnik odrobnik closed this Apr 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment