summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kaspar2013-12-05 05:25:25 (EST)
committerDoug Schaefer2013-12-05 18:33:54 (EST)
commit4546692659aab94d2cfe72c96e3922f64c78029e (patch)
tree0f7f9d6708d575f34034873e9946d08a34ae7eb1
parentbd84e07bc62eb24a354c659d5ebf618fcc5bcf60 (diff)
downloadorg.eclipse.cdt-4546692659aab94d2cfe72c96e3922f64c78029e.zip
org.eclipse.cdt-4546692659aab94d2cfe72c96e3922f64c78029e.tar.gz
org.eclipse.cdt-4546692659aab94d2cfe72c96e3922f64c78029e.tar.bz2
Bug 422797 - Fix for synchronization and update in QMakeProjectInforefs/changes/61/19361/3
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>
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfo.java43
1 files changed, 25 insertions, 18 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfo.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfo.java
index 331e662..37b354c 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfo.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/index/QMakeProjectInfo.java
@@ -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() {
- ControllerImpl previous = activeController;
- activeController = null;
- if (previous != null) {
- previous.destroy();
+ private void updateActiveConfiguration() {
+ synchronized (sync) {
+ if (! live) {
+ return;
+ }
+ ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescriptionManager().getProjectDescription(project);
+ setActiveConfiguration(projectDescription != null ? projectDescription.getActiveConfiguration() : null);
+ qmakeInfo = null;
}
+ notifyListeners();
}
- // updates active configuration
- private void updateActiveConfiguration() {
- ICConfigurationDescription configuration = projectDescription.getActiveConfiguration();
- if (configuration != null) {
- activeController = new ControllerImpl(configuration);
+ // called under synchronized (sync)
+ private void setActiveConfiguration(ICConfigurationDescription configuration) {
+ ControllerImpl previous = activeController;
+ activeController = configuration != null ? new ControllerImpl(configuration) : null;
+ if (previous != null) {
+ previous.destroy();
}
- 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();
}