Bug 411003 - Dialog are sometimes using fonts from the wrong Theme
Summary: Dialog are sometimes using fonts from the wrong Theme
Status: ASSIGNED
Alias: None
Product: RAP
Classification: RT
Component: Workbench (show other bugs)
Version: 2.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-18 06:22 EDT by Sebastien Arod CLA
Modified: 2013-06-18 17:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastien Arod CLA 2013-06-18 06:22:02 EDT
Reproducible cases:
* Open to the demo application with fancy theme (http://rap.eclipsesource.com/workbenchdemo/fancy)
* Open File>Import dialog.
* The font size of the wizard message is 12px;
* Open to the demo application with default theme in a new tab (http://rap.eclipsesource.com/workbenchdemo/workbench)
* Open the Import Dialog
=> Workbench Theme uses the fancy dialog fonts. This is WRONG


* Refresh the tab using the default theme. 
* Reopen the import dialog. Fonts are back to default theme fonts. (size is 14px).
* Refresh the tab using the fancy theme. 
* Reopen the import dialog. 
=> Fancy Theme uses default theme fonts... !!!


After debugging I found that the problem comes from the fact that ThemeElementHelper.installFont tries to find the font to use from PrefUtil.getInternalPreferenceStore() and fallback to fonts from JFace FontRegistry and then store the result in the PrefUtil.getInternalPreferenceStore().

And since PrefUtil.getInternalPreferenceStore() is of scope session you end up sharing this between UISessions.

Having the same user using multiple tabs with different themes can be seen as a corner case however in our case we have 2 workbench applications each with it's own theme and it's own set of perspective so it would be a frequent use case for us to have the same Session having to deal with 2 themes.


I currently worked around this by adding the following code in org.eclipse.equinox.app.IApplication.start(IApplicationContext) before workbench startup to make sure theme fonts are used by workbench theme:

<code>
// Try to avoid font leaking see Bug #923					
FontDefinition[] fontDefinitions = WorkbenchPlugin.getDefault()
	                .getThemeRegistry().getFonts();
FontRegistry jfaceFontRegistry = JFaceResources.getFontRegistry();        
for (FontDefinition fontDefinition : fontDefinitions) {
       	PreferenceConverter.setDefault(PrefUtil.getInternalPreferenceStore(), fontDefinition.getId(), jfaceFontRegistry.getFontData(fontDefinition.getId()));
}
</code>
Comment 1 Ivan Furnadjiev CLA 2013-06-18 06:44:57 EDT
Sebastien, see also bug 232983 and comment bug 232983 comment#2. What do you think?
Comment 2 Sebastien Arod CLA 2013-06-18 17:04:48 EDT
Prefixing the workbench preference key with entry point id for fonts would probably fix this issue in our case.

However changing the themeid in the url (I don't know if it's still possible but at some point the themeid was an optional parameter of the entrypoint url) would again create a conflict between the rwt theme and the workbench stored preferences without changing the entrypoint.

More generally I'm wondering if the workbench capability to store dialog fonts in preferences makes sense at all in rwt since the rwt theming provides a more powerfull mechanism to customize fonts.