Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
runAsyncWithProgress cannot target an UI element with no parent, wi…
Browse files Browse the repository at this point in the history
…ll no throw Exception with warning (#873)
  • Loading branch information
Edvin Syse committed Dec 27, 2018
1 parent d808d35 commit b5e8bd7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tornadofx/Async.kt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fun <T : Any> 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)
Expand Down

0 comments on commit b5e8bd7

Please sign in to comment.