From 16a526f089a8f9e0a25d4a40faaba32cc83e6e03 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Wed, 28 Feb 2024 17:23:09 +0100 Subject: [PATCH] Fix "Changing owner name crashes the application" (#10932) * Fix propagation of value change * Add CHANGELOG.md entry * Fix braces --- CHANGELOG.md | 1 + src/main/java/org/jabref/preferences/FilePreferences.java | 4 ++++ .../java/org/jabref/preferences/InternalPreferences.java | 4 ++++ src/main/java/org/jabref/preferences/JabRefPreferences.java | 6 ++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ff27dee5d0..c7c3bce47ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the preview panel showing the wrong entry (an entry that is not selected in the entry table). [#9172](https://github.com/JabRef/jabref/issues/9172) - We fixed an issue where HTML-reserved characters like '&' and '<', in addition to HTML entities like '&' were not rendered correctly in entry preview. [#10677](https://github.com/JabRef/jabref/issues/10677) - The last page of a PDF is now indexed by the full text search. [#10193](https://github.com/JabRef/jabref/issues/10193) +- The default owner of an entry can be changed again. [#10924](https://github.com/JabRef/jabref/issues/10924) - We fixed an issue where the duplicate check did not take umlauts or other LaTeX-encoded characters into account. [#10744](https://github.com/JabRef/jabref/pull/10744) - We fixed the colors of the icon on hover for unset special fields. [#10431](https://github.com/JabRef/jabref/issues/10431) - We fixed an issue where the CrossRef field did not work if autocompletion was disabled [#8145](https://github.com/JabRef/jabref/issues/8145) diff --git a/src/main/java/org/jabref/preferences/FilePreferences.java b/src/main/java/org/jabref/preferences/FilePreferences.java index 2dd43a55553..fe89be62899 100644 --- a/src/main/java/org/jabref/preferences/FilePreferences.java +++ b/src/main/java/org/jabref/preferences/FilePreferences.java @@ -71,6 +71,10 @@ public String getUserAndHost() { return userAndHost.getValue(); } + public StringProperty getUserAndHostProperty() { + return userAndHost; + } + public Optional getMainFileDirectory() { if (StringUtil.isBlank(mainFileDirectory.getValue())) { return Optional.empty(); diff --git a/src/main/java/org/jabref/preferences/InternalPreferences.java b/src/main/java/org/jabref/preferences/InternalPreferences.java index 0276dc88ca0..1850f23492a 100644 --- a/src/main/java/org/jabref/preferences/InternalPreferences.java +++ b/src/main/java/org/jabref/preferences/InternalPreferences.java @@ -71,6 +71,10 @@ public String getUserAndHost() { return userAndHost.get(); } + public StringProperty getUserAndHostProperty() { + return userAndHost; + } + public boolean isMemoryStickMode() { return memoryStickMode.get(); } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 30905020668..4fb73df336a 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1406,8 +1406,9 @@ public OwnerPreferences getOwnerPreferences() { put(DEFAULT_OWNER, newValue); // trigger re-determination of userAndHost and the dependent preferences userAndHost = null; - filePreferences = null; - internalPreferences = null; + + // this propagates down to filePreferences + getInternalPreferences().getUserAndHostProperty().setValue(newValue); }); EasyBind.listen(ownerPreferences.overwriteOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(OVERWRITE_OWNER, newValue)); @@ -2205,6 +2206,7 @@ public FilePreferences getFilePreferences() { getBoolean(CONFIRM_LINKED_FILE_DELETE), getBoolean(TRASH_INSTEAD_OF_DELETE)); + EasyBind.listen(getInternalPreferences().getUserAndHostProperty(), (obs, oldValue, newValue) -> filePreferences.getUserAndHostProperty().setValue(newValue)); EasyBind.listen(filePreferences.mainFileDirectoryProperty(), (obs, oldValue, newValue) -> put(MAIN_FILE_DIRECTORY, newValue)); EasyBind.listen(filePreferences.storeFilesRelativeToBibFileProperty(), (obs, oldValue, newValue) -> putBoolean(STORE_RELATIVE_TO_BIB, newValue)); EasyBind.listen(filePreferences.fileNamePatternProperty(), (obs, oldValue, newValue) -> put(IMPORT_FILENAMEPATTERN, newValue));