From a266dc46cb957caae1ab76d0eb420840e48d032e Mon Sep 17 00:00:00 2001 From: Edvin Syse Date: Mon, 30 Oct 2017 09:30:06 +0100 Subject: [PATCH] `fitToParentHeight/Width/Size` as well as `fitToHeight/Width/Size(region)` helpers (https://github.com/edvin/tornadofx/pull/519) --- CHANGELOG.md | 1 + src/main/java/tornadofx/Async.kt | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc204771e..709f8ac90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `alert` builder accepts optional owner parameter (https://github.com/edvin/tornadofx/issues/483) ### Additions +- `fitToParentHeight/Width/Size` as well as `fitToHeight/Width/Size(region)` helpers (https://github.com/edvin/tornadofx/pull/519) - `beforeShutdown` allows you to register shutdown hooks - `DataGridPaginator` component to help with pagination for `DataGrid` - runAsync supports `daemon` parameter to control thread characteristics (https://github.com/edvin/tornadofx/pull/508) diff --git a/src/main/java/tornadofx/Async.kt b/src/main/java/tornadofx/Async.kt index 7ef49a965..0cdb6f8f9 100644 --- a/src/main/java/tornadofx/Async.kt +++ b/src/main/java/tornadofx/Async.kt @@ -83,7 +83,15 @@ infix fun Task.ui(func: (T) -> Unit) = success(func) infix fun Task.success(func: (T) -> Unit) = apply { Platform.runLater { - setOnSucceeded { func(value) } + setOnSucceeded { + if (Platform.isFxApplicationThread()) { + func(value) + } else { + runLater { + func(value) + } + } + } } }