Mercurial > cgi-bin > hgweb.cgi > JpegWasher
changeset 20:965435b85a69
Get rid of some stuttering.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 12 Apr 2020 11:46:12 -0700 |
parents | 39b977021ea1 |
children | 539c3641c539 |
files | src/name/blackcap/exifwasher/Main.kt src/name/blackcap/exifwasher/Misc.kt |
diffstat | 2 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/name/blackcap/exifwasher/Main.kt Sat Apr 11 16:12:59 2020 -0700 +++ b/src/name/blackcap/exifwasher/Main.kt Sun Apr 12 11:46:12 2020 -0700 @@ -12,8 +12,8 @@ val MYNAME = "ExifWasher" /* global UI objects */ - var mainFrame: MainFrame by SetOnce<MainFrame>() - var settingsDialog: SettingsDialog by SetOnce<SettingsDialog>() + var mainFrame: MainFrame by setOnce() + var settingsDialog: SettingsDialog by setOnce() fun initialize() { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
--- a/src/name/blackcap/exifwasher/Misc.kt Sat Apr 11 16:12:59 2020 -0700 +++ b/src/name/blackcap/exifwasher/Misc.kt Sun Apr 12 11:46:12 2020 -0700 @@ -23,7 +23,7 @@ * needed in Swing, because some vars inevitably need to be declared at * outer levels but initialized in the Swing event dispatch thread. */ -class SetOnce<T: Any>: ReadWriteProperty<Any?,T> { +class SetOnceImpl<T>: ReadWriteProperty<Any?,T> { private var setOnceValue: T? = null override operator fun getValue(thisRef: Any?, property: KProperty<*>): T { @@ -43,6 +43,8 @@ } } +fun <T> setOnce(): SetOnceImpl<T> = SetOnceImpl<T>() + /** * Run something in the Swing thread, asynchronously. * @param block lambda containing code to run