Skip to content

Commit f507810

Browse files
committed
LogFormatter: persist only when prefKey is set
1 parent 9930a72 commit f507810

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/scijava/ui/swing/console/LogFormatter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private void printWithBrackets(PrintWriter printer, String prefix) {
114114
// -- Helper methods --
115115

116116
public void applySettings() {
117-
if(prefService == null) return;
117+
if (skipPersist()) return;
118118
Map<String, String> settings = prefService.getMap(prefKey);
119119
for(Field field : Field.values()) {
120120
String defaultValue = Boolean.toString(isVisible(field));
@@ -125,9 +125,13 @@ public void applySettings() {
125125
}
126126

127127
public void changeSetting(Field field, boolean visible) {
128-
if(prefService == null) return;
128+
if (skipPersist()) return;
129129
Map<String, String> settings = prefService.getMap(LogFormatter.class, prefKey);
130130
settings.put(field.toString(), Boolean.toString(visible));
131131
prefService.putMap(LogFormatter.class, settings, prefKey);
132132
}
133+
134+
private boolean skipPersist() {
135+
return prefService == null || prefKey == null || prefKey.isEmpty();
136+
}
133137
}

0 commit comments

Comments
 (0)