Community
Participate
Working Groups
Created attachment 193318 [details] patch to fix target sync Turns out that in the target management implementation TargetDefinition instances are created and recreated at will. In the p2 profile synchronization management implementation we assume that the "synchronizer" (P2TargetUtils) can point to one TargetDefinition and one Profile and keep them in sync. This causes problems if, for example, a target editor is open on a target in the workspace and that target def is updated or a garbage collection happens. In that case, the editor sees the underlying .target resource change and so reloads. But the reloaded TargetDefinition is different from the one that was used for synchronizing with the p2 profile. Confusion ensues... Ideally I think the target management infrastructure if overly complicated but pragmatically, its what we have so we have to work around. To address this problem I've changed the P2TargetUtils instances to NOT retain a pointer to the actual TargetDefinition rather they retain their "memento" (unique identifier). This is used as the key in a map from memento to synchronizer. This decouples the two. As a result, a number of methods in P2TargetUtils and IUBundleContainer were changed to take a TargetDefinition as an arg rather than using the old fTarget field. That's only part of the story. Because the synchronizer is the focus all the real work (i.e., profile resolution, ...) previously, when the profile was found to be sync with the target we would "notify" the target of changes and the target/containers would recache their bundles and features. Since there can actually be multiple TargetDefinition object working against the same profile/synchronizer, I modified the synchronize() method to always notify the target. This will be a little inefficient but in the grand scheme of things should not be too painful. Please check out the patch and see if you agree with the direction. Note that without this fix I was getting various "profile out of sync" errors when doing more complicated things with targets so fixing this for 3.7 would be highly desirable.
I agree with the direction. Better solutions would involve changing the architecture and API of target definitions.
Fixed in HEAD. We will have to include some more indepth testing of the p2 targets in either the M7 pass or the 2-day pass in RC1.