diff --git a/CHANGELOG.md b/CHANGELOG.md index fdea240e3..193cb0075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `config` no longer accepts null values, as the underlying `Properties` store won't allow them (https://github.com/edvin/tornadofx/issues/792). The set function that takes Pair still accepts null as the value, but will remove the key if the value is null. - the `di()` delegate no longer calls out to the `DIContainer` for every access, effectively caching the lookup (https://github.com/edvin/tornadofx/issues/837) - More efficient timer for delayed `runLater` calls (https://github.com/edvin/tornadofx/pull/836) +- `runAsyncWithProgress` cannot target an UI element with no parent, will no throw Exception with warning (https://github.com/edvin/tornadofx/issues/873) ### Changes diff --git a/src/main/java/tornadofx/Async.kt b/src/main/java/tornadofx/Async.kt index 3f7b53106..38cba5cc0 100644 --- a/src/main/java/tornadofx/Async.kt +++ b/src/main/java/tornadofx/Async.kt @@ -257,7 +257,7 @@ fun Node.runAsyncWithProgress(progress: Node = ProgressIndicator(), op val paddingVertical = (this as? Region)?.paddingVertical?.toDouble() ?: 0.0 (progress as? Region)?.setPrefSize(boundsInParent.width - paddingHorizontal, boundsInParent.height - paddingVertical) // Unwrap ToolBar parent, it has an extra HBox or VBox inside it, we need to target the items list - val p = (parent?.parent as? ToolBar) ?: parent + val p = (parent?.parent as? ToolBar) ?: parent ?: throw IllegalArgumentException("runAsyncWithProgress cannot target an UI element with no parent!") val children = requireNotNull(p.getChildList()) { "This node has no child list, and cannot contain the progress node" } val index = children.indexOf(this) children.add(index, progress)