Fix premature garbage collection with preference dialog spinners

This commit is contained in:
Marvin Elsen 2024-11-11 20:38:35 +01:00
parent 52acfeb5da
commit e4f7e8ee5d
Signed by: marvinelsen
GPG Key ID: 820672408CC318C2

View File

@ -49,13 +49,6 @@ class PreferencesDialogController(private val config: Config) {
@FXML
private lateinit var spinnerDefinitionFontSizeSearchResults: Spinner<Int>
private val entryHeadwordFontSizeObjectProperty = config.details.headwordFontSize.asObject()
private val entryPronunciationFontSizeObjectProperty = config.details.pronunciationFontSize.asObject()
private val searchResultHeadwordFontSizeObjectProperty = config.searchResults.headwordFontSize.asObject()
private val searchResultPronunciationFontSizeObjectProperty = config.searchResults.pronunciationFontSize.asObject()
private val searchResultDefinitionFontSizeObjectProperty = config.searchResults.definitionFontSize.asObject()
@FXML
private fun initialize() {
comboBoxLocale.items.addAll(
@ -82,27 +75,42 @@ class PreferencesDialogController(private val config: Config) {
with(spinnerHeadwordFontSizeDetails) {
editor.textFormatter = FontSizeTextFormatter()
valueFactory.valueProperty().bindBidirectional(entryHeadwordFontSizeObjectProperty)
valueFactory.value = config.details.headwordFontSize.value
valueProperty().addListener { _, _, newValue ->
config.details.headwordFontSize.value = newValue
}
}
with(spinnerPronunciationFontSizeDetails) {
editor.textFormatter = FontSizeTextFormatter()
valueFactory.valueProperty().bindBidirectional(entryPronunciationFontSizeObjectProperty)
valueFactory.value = config.details.pronunciationFontSize.value
valueProperty().addListener { _, _, newValue ->
config.details.pronunciationFontSize.value = newValue
}
}
with(spinnerHeadwordFontSizeSearchResults) {
editor.textFormatter = FontSizeTextFormatter()
valueFactory.valueProperty().bindBidirectional(searchResultHeadwordFontSizeObjectProperty)
valueFactory.value = config.searchResults.headwordFontSize.value
valueProperty().addListener { _, _, newValue ->
config.searchResults.headwordFontSize.value = newValue
}
}
with(spinnerPronunciationFontSizeSearchResults) {
editor.textFormatter = FontSizeTextFormatter()
valueFactory.valueProperty().bindBidirectional(searchResultPronunciationFontSizeObjectProperty)
valueFactory.value = config.searchResults.pronunciationFontSize.value
valueProperty().addListener { _, _, newValue ->
config.searchResults.pronunciationFontSize.value = newValue
}
}
with(spinnerDefinitionFontSizeSearchResults) {
editor.textFormatter = FontSizeTextFormatter()
valueFactory.valueProperty().bindBidirectional(searchResultDefinitionFontSizeObjectProperty)
valueFactory.value = config.searchResults.definitionFontSize.value
valueProperty().addListener { _, _, newValue ->
config.searchResults.definitionFontSize.value = newValue
}
}
}
}