mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
fixed NPE when invoking listeners
This commit is contained in:
parent
b52f8d0624
commit
01619cd230
1 changed files with 23 additions and 25 deletions
|
@ -59,8 +59,6 @@ public class DiscoveredPathManager implements IDiscoveredPathManager {
|
||||||
public static final String SYMBOL = "symbol"; //$NON-NLS-1$
|
public static final String SYMBOL = "symbol"; //$NON-NLS-1$
|
||||||
public static final String REMOVED = "removed"; //$NON-NLS-1$
|
public static final String REMOVED = "removed"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String ROOT_ELEM_NAME = "DiscoveredScannerInfo"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private Map fDiscoveredMap = new HashMap();
|
private Map fDiscoveredMap = new HashMap();
|
||||||
private List listeners = Collections.synchronizedList(new Vector());
|
private List listeners = Collections.synchronizedList(new Vector());
|
||||||
|
|
||||||
|
@ -98,7 +96,8 @@ public class DiscoveredPathManager implements IDiscoveredPathManager {
|
||||||
fireUpdate(INFO_CHANGED, info);
|
fireUpdate(INFO_CHANGED, info);
|
||||||
ICProject cProject = CoreModel.getDefault().create(info.getProject());
|
ICProject cProject = CoreModel.getDefault().create(info.getProject());
|
||||||
if (cProject != null) {
|
if (cProject != null) {
|
||||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(info.getProject()), null);
|
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject},
|
||||||
|
new DiscoveredPathContainer(info.getProject()), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,9 +246,9 @@ public class DiscoveredPathManager implements IDiscoveredPathManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
|
private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
|
||||||
synchronized (listeners) {
|
Object[] list = listeners.toArray();
|
||||||
final Iterator iterator = listeners.iterator();
|
for (int i = 0; i < list.length; i++) {
|
||||||
while (iterator.hasNext()) {
|
final IDiscoveredInfoListener listener = (IDiscoveredInfoListener)list[i];
|
||||||
Platform.run(new ISafeRunnable() {
|
Platform.run(new ISafeRunnable() {
|
||||||
|
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
|
@ -261,17 +260,16 @@ public class DiscoveredPathManager implements IDiscoveredPathManager {
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INFO_CHANGED :
|
case INFO_CHANGED :
|
||||||
((IDiscoveredInfoListener)iterator.next()).infoChanged(info);
|
listener.infoChanged(info);
|
||||||
break;
|
break;
|
||||||
case INFO_REMOVED :
|
case INFO_REMOVED :
|
||||||
((IDiscoveredInfoListener)iterator.next()).infoRemoved(info.getProject());
|
listener.infoRemoved(info.getProject());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void addDiscoveredInfoListener(IDiscoveredInfoListener listener) {
|
public void addDiscoveredInfoListener(IDiscoveredInfoListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
|
|
Loading…
Add table
Reference in a new issue