Community
Participate
Working Groups
Build Identifier: 20100917-0705 FontFieldEditor is used to select a font in a preference page. Code that reacts to font changes register an IPropertyChangeListener with the PreferenceStore. When a new font is chosen this listener is invoked with a FontData[] instance as the new value. But when the "Restore Defaults" button is clicked on the preference page, the listener is called with a String representation of the default font. Note, I use PreferenceConverter.setDefault(store, FONT, defaultFont) to initialized the default font in the preference store. Stack trace showing the call path: ... at org.eclipse.jface.preference.PreferenceStore$1.run(PreferenceStore.java:136) at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.preference.PreferenceStore.firePropertyChangeEvent(PreferenceStore.java:133) at org.eclipse.jface.preference.PreferenceStore.setToDefault(PreferenceStore.java:565) at org.eclipse.jface.preference.FieldEditor.store(FieldEditor.java:678) at org.eclipse.jface.preference.FieldEditorPreferencePage.performOk(FieldEditorPreferencePage.java:343) at org.eclipse.jface.preference.PreferencePage.performApply(PreferencePage.java:432) ... When FieldEditor.store() is called it does this: ... if (isDefaultPresented) { preferenceStore.setToDefault(preferenceName); } else { doStore(); } ... Note, FontFieldEditor#setToDefault() does do the right thing. But I don't see anyone calling it. I think the fix would be to call instead of calling setToDefault above: protected void setToDefault() { FontData[] defaultFontData = PreferenceConverter.getDefaultFontDataArray(getPreferenceStore(), getPreferenceName()); PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), defaultFontData); } Easy enough (but ugly) to workaround by checking argument type and re-parsing String into FontData instance. Reproducible: Always
Can you please explain what the impact is? Is any code failing due to the unexpected value from FontFieldEditor?
Could you please attach a minimal test project that reproduces the issue?
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.