Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349511

Summary: Project-level preferences are being applied to all projects in a workspace
Product: [Modeling] TMF Reporter: Alex Ruiz <alruiz>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: SR1   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Alex Ruiz CLA 2011-06-15 19:28:22 EDT
Build Identifier: I20110526-1708

When changing preferences for a particular project, the changes get saved to all the projects in the workspace.

After some debugging, I think the problem is in PreferenceStoreAccessImpl, in the method getWritablePreferenceStore(Object), line 59:

Code: [Select all] [Show/ hide]
	public IPreferenceStore getWritablePreferenceStore(Object context) {
		lazyInitialize();
		if (context instanceof IFileEditorInput) {
			context = ((IFileEditorInput) context).getFile().getProject();
		}
		if (context instanceof IProject) {
			ProjectScope projectScope = new ProjectScope((IProject) context);
			ScopedPreferenceStore result = new ScopedPreferenceStore(projectScope, getQualifier());
			result.setSearchContexts(new IScopeContext[] {
				projectScope,
				new InstanceScope(),
				new ConfigurationScope()
			});
		}
		return getWritablePreferenceStore();
	}


when the context is a IProject, this method creates a ScopedPreferenceStore using the passed IProject as one of the scopes. I think the problem is, the created ScopedPreferenceStore is never returned, instead, this method always returns the one from getWritablePreferenceStore().


Reproducible: Always

Steps to Reproduce:
This is my use case. I have a Xtext-based editor that has preference pages at the project level. Every time I save preferences for one project, the rest of projects in the same workspace get such preferences as well.

Reference: http://www.eclipse.org/forums/index.php/m/677591/#msg_677591
Comment 1 Sebastian Zarnekow CLA 2011-06-16 14:48:34 EDT
Pushed to master.
Comment 2 Karsten Thoms CLA 2017-09-19 18:04:18 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 18:14:21 EDT
Closing all bugs that were set to RESOLVED before Neon.0