From b7be570271769e93bd05cddeefd5a358e820b376 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 24 May 2023 09:56:02 +0300 Subject: [PATCH] Fix property listener --- .../pimotionmaster/fxDeviceProperties.kt | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt b/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt index e8b4e68..93f9f7c 100644 --- a/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt +++ b/demo/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/fxDeviceProperties.kt @@ -12,8 +12,8 @@ import tornadofx.* /** * Bind a FX property to a device property with a given [spec] */ -fun Device.fxProperty( - spec: DevicePropertySpec +fun D.fxProperty( + spec: DevicePropertySpec, ): ReadOnlyProperty = object : ObjectPropertyBase() { override fun getBean(): Any = this override fun getName(): String = spec.name @@ -21,16 +21,12 @@ fun Device.fxProperty( init { //Read incoming changes onPropertyChange(spec) { - if (it != null) { - runLater { - try { - set(it) - } catch (ex: Throwable) { - logger.info { "Failed to set property $name to $it" } - } + runLater { + try { + set(it) + } catch (ex: Throwable) { + logger.info { "Failed to set property $name to $it" } } - } else { - invalidated() } } }