Bug 307129 Window context never disposed
1) Run Window->Open Window in legacy IDE -> A context is created for the new window 2) Close the new window -> The context is not disposed
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/internal/SelectionServiceImpl.java
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.ContextChangeEvent;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.IRunAndTrack;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.di.annotations.PostConstruct;
import org.eclipse.e4.core.di.annotations.PreDestroy;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.ui.MContext;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.workbench.modeling.EPartService;
import org.eclipse.e4.workbench.modeling.ESelectionService;
import org.eclipse.e4.workbench.modeling.ISelectionListener;
import org.eclipse.e4.workbench.ui.UIEvents;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
public class SelectionServiceImpl implements ESelectionService {
	static final String OUT_SELECTION = "output.selection"; 
	private Set<ISelectionListener> genericListeners = new HashSet<ISelectionListener>();
	private Map<String, Set<ISelectionListener>> targetedListeners = new HashMap<String, Set<ISelectionListener>>();
	private Set<IEclipseContext> tracked = new HashSet<IEclipseContext>();
	@Inject
	private IEclipseContext context;
	@Inject
	private EPartService partService;
	/**
	 * This is the specific implementation. TODO: generalize it