mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 422797 - Fix for synchronization and update in QMakeProjectInfo
handleEvent method updates for related project only and does not fire listeners under 'sync' lock. Change-Id: Id9726925ff9c044a3c13238406bdf3228ccf2933 Signed-off-by: David Kaspar <dkaspar@blackberry.com> Reviewed-on: https://git.eclipse.org/r/19361 Reviewed-by: Andrew Eidsness <eclipse@jfront.com> Reviewed-by: Doug Schaefer <dschaefer@qnx.com> IP-Clean: Doug Schaefer <dschaefer@qnx.com> Tested-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
bd84e07bc6
commit
4546692659
1 changed files with 25 additions and 18 deletions
|
@ -106,7 +106,7 @@ public final class QMakeProjectInfo implements IQMakeProjectInfo, ICProjectDescr
|
|||
}
|
||||
}
|
||||
|
||||
private final ICProjectDescription projectDescription;
|
||||
private final IProject project;
|
||||
|
||||
// sync object for all mutable fields
|
||||
private final Object sync = new Object();
|
||||
|
@ -122,7 +122,7 @@ public final class QMakeProjectInfo implements IQMakeProjectInfo, ICProjectDescr
|
|||
private final List<IQMakeProjectInfoListener> listeners = new CopyOnWriteArrayList<IQMakeProjectInfoListener>();
|
||||
|
||||
private QMakeProjectInfo(IProject project) {
|
||||
projectDescription = CoreModel.getDefault().getProjectDescriptionManager().getProjectDescription(project);
|
||||
this.project = project;
|
||||
CoreModel.getDefault().addCProjectDescriptionListener(this, ICDescriptionDelta.ACTIVE_CFG);
|
||||
updateActiveConfiguration();
|
||||
}
|
||||
|
@ -135,36 +135,39 @@ public final class QMakeProjectInfo implements IQMakeProjectInfo, ICProjectDescr
|
|||
}
|
||||
live = false;
|
||||
CoreModel.getDefault().removeCProjectDescriptionListener(this);
|
||||
removeActiveConfiguration();
|
||||
setActiveConfiguration(null);
|
||||
qmakeInfo = QMakeInfo.INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
// removes active configuration
|
||||
private void removeActiveConfiguration() {
|
||||
private void updateActiveConfiguration() {
|
||||
synchronized (sync) {
|
||||
if (! live) {
|
||||
return;
|
||||
}
|
||||
ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescriptionManager().getProjectDescription(project);
|
||||
setActiveConfiguration(projectDescription != null ? projectDescription.getActiveConfiguration() : null);
|
||||
qmakeInfo = null;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// called under synchronized (sync)
|
||||
private void setActiveConfiguration(ICConfigurationDescription configuration) {
|
||||
ControllerImpl previous = activeController;
|
||||
activeController = null;
|
||||
activeController = configuration != null ? new ControllerImpl(configuration) : null;
|
||||
if (previous != null) {
|
||||
previous.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// updates active configuration
|
||||
private void updateActiveConfiguration() {
|
||||
ICConfigurationDescription configuration = projectDescription.getActiveConfiguration();
|
||||
if (configuration != null) {
|
||||
activeController = new ControllerImpl(configuration);
|
||||
}
|
||||
scheduleFetchQMakeInfo();
|
||||
}
|
||||
|
||||
// called on active project configuration change
|
||||
@Override
|
||||
public void handleEvent(CProjectDescriptionEvent event) {
|
||||
synchronized (sync) {
|
||||
removeActiveConfiguration();
|
||||
updateActiveConfiguration();
|
||||
if (event.getProject() != project) {
|
||||
return;
|
||||
}
|
||||
updateActiveConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -270,6 +273,10 @@ public final class QMakeProjectInfo implements IQMakeProjectInfo, ICProjectDescr
|
|||
}
|
||||
qmakeInfo = null;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
private void notifyListeners() {
|
||||
for (IQMakeProjectInfoListener listener : listeners) {
|
||||
listener.qmakeInfoChanged();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue