@Override
	public void processEvent(PluginEvent event) {
		if (event instanceof ProgramClosedPluginEvent) {
			Program program = ((ProgramClosedPluginEvent) event).getProgram();
			programClosed(program);
			return;
		}
		if (connectedProvider == null) {
			return;
		}

		if (event instanceof ProgramActivatedPluginEvent) {
			currentProgram = ((ProgramActivatedPluginEvent) event).getActiveProgram();
			connectedProvider.doSetProgram(currentProgram);
			if (currentProgram != null) {
				SpecExtension.registerOptions(currentProgram);
			}
		}
		else if (event instanceof ProgramLocationPluginEvent) {
			ProgramLocation location = ((ProgramLocationPluginEvent) event).getLocation();
			Address address = location.getAddress();
			if (address.isExternalAddress()) {
				return;
			}
			if (currentProgram != null) {
				Listing listing = currentProgram.getListing();
				CodeUnit codeUnit = listing.getCodeUnitContaining(address);
				if (codeUnit instanceof Data) {
					return;
				}
			}
			currentLocation = location;
			// delay location change to allow immediate location changes to
			// settle down.  This happens when switching program tabs in
			// code browser which produces multiple location changes
			delayedLocationUpdateMgr.updateLater();
		}
		else if (event instanceof ProgramSelectionPluginEvent) {
			currentSelection = ((ProgramSelectionPluginEvent) event).getSelection();
			connectedProvider.setSelection(currentSelection);
		}

	}
Delay location changes to allow location events to settle down. This happens when a
readDataState occurs when a tool is restored or when switching program tabs.
Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilePlugin.java