forked from qt-creator/qt-creator
		
	CppTools: Fix using updated project part
1. Open a project consisting of two subprojects referencing the same source file. 2. Open the source file. 3. Click '#' in the editor toolbar and select the second project (part). 4. Update the project file, e.g. add a define ==> Editor does not reflect the added define This is due to comparing project part pointers. Fix by using the project part id that remains stable across project manager updates. Change-Id: Ifd1a113e55ebe2ecf036cd7caafdbfd6e4cdf415 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
		| @@ -51,7 +51,7 @@ protected: | ||||
|     QString filePath; | ||||
|     ProjectPartInfo currentProjectPartInfo{ProjectPart::Ptr(new ProjectPart), | ||||
|                                            ProjectPartInfo::NoHint}; | ||||
|     ProjectPart::Ptr manuallySetProjectPart; | ||||
|     QString preferredProjectPartId; | ||||
|     const ProjectExplorer::Project *activeProject = nullptr; | ||||
|     bool projectHasChanged = false; | ||||
|     Language languagePreference = Language::Cxx; | ||||
| @@ -64,11 +64,14 @@ protected: | ||||
|  | ||||
| TEST_F(ProjectPartChooser, ChooseManuallySet) | ||||
| { | ||||
|     manuallySetProjectPart.reset(new ProjectPart); | ||||
|     ProjectPart::Ptr p1(new ProjectPart); | ||||
|     ProjectPart::Ptr p2(new ProjectPart); | ||||
|     p2->projectFile = preferredProjectPartId = "someId"; | ||||
|     projectPartsForFile += {p1, p2}; | ||||
|  | ||||
|     const ProjectPart::Ptr chosen = choose().projectPart; | ||||
|  | ||||
|     ASSERT_THAT(chosen, Eq(manuallySetProjectPart)); | ||||
|     ASSERT_THAT(chosen, Eq(p2)); | ||||
| } | ||||
|  | ||||
| TEST_F(ProjectPartChooser, ForMultipleChoosePrevious) | ||||
| @@ -249,7 +252,7 @@ const ProjectPartInfo ProjectPartChooser::choose() const | ||||
| { | ||||
|     return chooser.choose(filePath, | ||||
|                           currentProjectPartInfo, | ||||
|                           manuallySetProjectPart, | ||||
|                           preferredProjectPartId, | ||||
|                           activeProject, | ||||
|                           languagePreference, | ||||
|                           projectHasChanged); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user