Skip to content

Commit 126ef16

Browse files
committed
Fix bug, that preferences where not stored
1 parent b54aefd commit 126ef16

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/priority/PriorityDescriptorCache.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public void dumpTo(PrintStream out) {
4242
public void loadFromPreferences() {
4343
IPreferences preferences = preferencesManager().loadPreferences();
4444
for (RulePriority rp : UISettings.currentPriorities(true)) {
45+
// note: the priority descriptors are cloned here, so that any changes to them
46+
// does not automatically get stored. Changes might occur while configuring the
47+
// preferences, but the user might cancel.
4548
uiDescriptorsByPriority.put(rp, preferences.getPriorityDescriptor(rp).clone());
4649
}
4750
refreshImages();
@@ -54,7 +57,7 @@ public void storeInPreferences() {
5457
for (Map.Entry<RulePriority, PriorityDescriptor> entry : uiDescriptorsByPriority.entrySet()) {
5558
prefs.setPriorityDescriptor(entry.getKey(), entry.getValue());
5659
}
57-
mgr.storePreferences(prefs);
60+
prefs.sync();
5861
// recreate images with the changed settings
5962
refreshImages();
6063
}
@@ -64,11 +67,11 @@ public PriorityDescriptor descriptorFor(RulePriority priority) {
6467
}
6568

6669
public boolean hasChanges() {
67-
IPreferences preferences = preferencesManager().reloadPreferences();
70+
IPreferences currentPreferences = preferencesManager().loadPreferences();
6871

6972
for (RulePriority rp : UISettings.currentPriorities(true)) {
7073
PriorityDescriptor newOne = uiDescriptorsByPriority.get(rp);
71-
PriorityDescriptor currentOne = preferences.getPriorityDescriptor(rp);
74+
PriorityDescriptor currentOne = currentPreferences.getPriorityDescriptor(rp);
7275
if (newOne.equals(currentOne)) {
7376
continue;
7477
}

0 commit comments

Comments
 (0)