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

Bug 315810

Summary: CModelManager.getSharedWorkingCopy() always create a new WorkingCopy
Product: [Tools] CDT Reporter: Vivian Kong <vivkong>
Component: cdt-editorAssignee: Vivian Kong <vivkong>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, mschorn.eclipse
Version: 7.0Flags: cdtdoug: review+
Target Milestone: 7.0   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Vivian Kong CLA 2010-06-04 13:54:31 EDT
I think this was missed when the method was moved from TranslationUnit.  I'd like to have this change in CDT 7.0.

Here's my proposed patch (1 line change):

### Eclipse Workspace Patch 1.0
#P org.eclipse.cdt.core
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.138
diff -u -r1.138 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java	20 Feb 2010 10:51:38 -0000	1.138
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java	4 Jun 2010 17:51:55 -0000
@@ -1374,7 +1374,7 @@
 			perFactoryWorkingCopies = new HashMap<ITranslationUnit, WorkingCopy>();
 			sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
 		}
-		WorkingCopy workingCopy = perFactoryWorkingCopies.get(this);
+		WorkingCopy workingCopy = perFactoryWorkingCopies.get(tu);
 		if (workingCopy != null) {
 			workingCopy.useCount++;
 			return workingCopy;
Comment 1 Vivian Kong CLA 2010-06-04 14:31:01 EDT
Fixed in HEAD
Comment 2 Doug Schaefer CLA 2010-06-04 14:33:11 EDT
Looks good. I'm not sure why this didn't produce a compile error with the templated Map.
Comment 3 CDT Genie CLA 2010-06-04 15:23:04 EDT
*** cdt cvs genie on behalf of vkong ***
Bug 315810 CModelManager.getSharedWorkingCopy() always create a new WorkingCopy

[*] CModelManager.java 1.139 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java?root=Tools_Project&r1=1.138&r2=1.139