Bug 425716 - Resource specific toolchain settings removed with (CDT)configuration specific resource filter
Summary: Resource specific toolchain settings removed with (CDT)configuration specific...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-15 01:12 EST by Raphael Zulliger CLA
Modified: 2020-09-04 15:25 EDT (History)
1 user (show)

See Also:


Attachments
Eclipse plugin that implements a resource filter to reproduce this bug (3.33 KB, application/zip)
2014-01-15 01:12 EST, Raphael Zulliger CLA
no flags Details
Sample CDT project to reproduce the bug (5.96 KB, application/zip)
2014-01-15 01:12 EST, Raphael Zulliger CLA
no flags Details
Proposed patch for a) (791 bytes, patch)
2014-01-15 01:13 EST, Raphael Zulliger CLA
no flags Details | Diff
Proposed patch for b) (1.02 KB, patch)
2014-01-15 01:13 EST, Raphael Zulliger CLA
no flags Details | Diff
Proposed patch for c) (2.95 KB, patch)
2014-01-15 01:13 EST, Raphael Zulliger CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Zulliger CLA 2014-01-15 01:12:06 EST
Created attachment 238990 [details]
Eclipse plugin that implements a resource filter to reproduce this bug

Resource specific toolchain settings removed with (CDT)configuration specific resource filter

How to reproduce:
  * Create an Eclipse-Plugin, implementing a resource filter (extension point 'org.eclipse.core.resources.filterMatchers'). That filter should "filter certain resources (i.e. a .cpp or a folder) depending on the active configuration"
  * Create a C/C++ project that contains a resource that get's filtered out for a certain configuration
  * Set file specific toolchain settings for that file that'll be filtered out for a certain configuration (e.g. set a compiler directive for that file)
  * Switch the configuration so that the file with the specific toolchain settings will be filtered out (means: is not visible in the Project Explorer anymore)
  * (maybe manually start a refresh on the project level to actually cause the resources to disappear - this may be worth filing another bug?)
  * Switch back to the previous configuration (in which the file re-appears)
  * (maybe manually start a refresh on the project level to actually cause the resources to disappear - this may be worth filing another bug?)

=> BUG: The resource specific settings have been removed!

In order to make it easier to reproduce the problem, I attached:
  * An Eclipse plugin implementing such a filter
  * A CDT project containing a "filtered resource (1 .c file an 1 folder) with resource specific settings"

Root cause: The code that causes the resource specific settings to be removed is located in org.eclipse.cdt.internal.core.settings.model.ResourceChangeHandler.RcMoveHandler.done(). That code intentionally removes all file specific settings for resources that got (re)moved. It does this for all configurations of a project. In other words: That piece of code assumes that all configurations of a project are using the same resources - which is not necessarily the case, as shown with the use case of a custom resource filters.

Other side-effects: Beside removing file specific settings, this also causes changes in the .cproject file whenever changin the active configuration...

Fixes I can think of:
  a) Remove resource specific settings only for "*removed* resources" if the resource is not filtered out
  b) Remove resource specific settings only for "*removed* resources" if the resource doesn't exist on the file system anymore
  c) Remove resource specific settings only for the active configuration (instead of "all configurations)

Personally, I prefer a) or b). I could push a patch to gerrit, once we've decided how to fix the issue.

Probably relevant/similar bugs: 311189, 317783 and 348569.
Comment 1 Raphael Zulliger CLA 2014-01-15 01:12:49 EST
Created attachment 238991 [details]
Sample CDT project to reproduce the bug
Comment 2 Raphael Zulliger CLA 2014-01-15 01:13:21 EST
Created attachment 238992 [details]
Proposed patch for a)
Comment 3 Raphael Zulliger CLA 2014-01-15 01:13:35 EST
Created attachment 238993 [details]
Proposed patch for b)
Comment 4 Raphael Zulliger CLA 2014-01-15 01:13:51 EST
Created attachment 238994 [details]
Proposed patch for c)
Comment 5 Raphael Zulliger CLA 2014-01-15 01:25:52 EST
I just reproduced this bug with today's master.
Comment 6 Nathan Ridge CLA 2017-02-18 21:12:32 EST
Please consider submitting your patches via Gerrit: https://wiki.eclipse.org/CDT/git#Using_Gerrit_for_CDT