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

Make children immutable to avoid concurrent modification exception #387

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KovalevAndrey
Copy link
Contributor

Make children immutable to avoid concurrent modification exception and check if Node has been destroyed before calling lifecycle events

Description:

Related issue(s):

…d check if Node has been destroyed before calling lifecycle events
@@ -237,7 +256,8 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
@MainThread
fun attachChildNode(child: Node<*>) {
verifyNotRoot(child)
_children.add(child)
val newChildren = children.toMutableList().apply { add(child) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

children + child instead?

@@ -99,6 +99,8 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
is AncestryInfo.Child -> ancestryInfo.anchor
}

private var isDestroyed: Boolean = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

get() = lifecycleManager.ribLifecycle.state == Lifecycle.DESTROYED to eliminate possibility of desynchronisation of properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants