Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315810 - CModelManager.getSharedWorkingCopy() always create a new WorkingCopy
Summary: CModelManager.getSharedWorkingCopy() always create a new WorkingCopy
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Vivian Kong CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-04 13:54 EDT by Vivian Kong CLA
Modified: 2010-06-04 15:23 EDT (History)
2 users (show)

See Also:
cdtdoug: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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