diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java index 36e69dc548..da5707d7d8 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java @@ -125,9 +125,8 @@ public class DataTypeManagerPlugin extends ProgramPlugin @Override public void archiveClosed(Archive archive) { if (archive instanceof ProjectArchive) { - // Program is handled by deactivation event - ((ProjectArchive) archive).getDomainObject().removeListener( - DataTypeManagerPlugin.this); + ProjectArchive projectArchive = (ProjectArchive) archive; + projectArchive.getDomainObject().removeListener(DataTypeManagerPlugin.this); } } @@ -137,11 +136,10 @@ public class DataTypeManagerPlugin extends ProgramPlugin addRecentlyOpenedArchiveFile(((FileArchive) archive).getFile()); } else if (archive instanceof ProjectArchive) { - ((ProjectArchive) archive).getDomainObject().addListener( - DataTypeManagerPlugin.this); + ProjectArchive projectArchive = (ProjectArchive) archive; + projectArchive.getDomainObject().addListener(DataTypeManagerPlugin.this); addRecentlyOpenedProjectArchive((ProjectArchive) archive); } - // Program is handled by activation. } @Override @@ -267,8 +265,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin @Override public void dispose() { tool.removePopupActionProvider(this); - provider.dispose(); - close(); + dataTypeManagerHandler.closeAllArchives(); dataTypeManagerHandler.dispose(); } @@ -347,7 +344,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin @Override protected void close() { - dataTypeManagerHandler.closeAllArchives(); + provider.dispose(); } public DataTypeManagerHandler getDataTypeManagerHandler() { diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/Plugin.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/Plugin.java index 54ff0fd681..16617d98bb 100644 --- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/Plugin.java +++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/Plugin.java @@ -17,6 +17,7 @@ package ghidra.framework.plugintool; import java.util.*; +import docking.ComponentProvider; import docking.action.DockingAction; import ghidra.framework.main.*; import ghidra.framework.model.DomainFile; @@ -112,10 +113,11 @@ import ghidra.util.classfinder.ExtensionPoint; * calls the {@link PluginTool#getService(Class)} method. *
* Conversely, any services your Plugin advertises in @PluginInfo must be published via calls to - * {@link #registerServiceProvided(Class, Object) registerServiceProvided()} in your Plugin's constructor. + * {@link #registerServiceProvided(Class, Object) registerServiceProvided()} in your Plugin's + * constructor. *
- * Cyclic dependencies are not allowed and will cause the Plugin management code to fail to load - * your Plugin. (ie. PluginA requires a service that PluginB provides, which requires a service + * Cyclic dependencies are not allowed and will cause the Plugin management code to fail to + * load your Plugin. (ie. PluginA requires a service that PluginB provides, which requires a service * that PluginA provides) * *
public MyPlugin(PluginTool tool) {
...
MyService serviceObj = new MyService() { ... };
registerServiceProvided(MyService.class, serviceObj);
registerServiceProvided(MyService.class, serviceObj);
+ *
}
* When your Plugin directly implements the advertised service interface, you should not @@ -159,26 +162,27 @@ import ghidra.util.classfinder.ExtensionPoint; *
* Deprecated, use {@link PluginUtils#getPluginNameFromClass(Class)} *
- * @param pluginClass + * @param pluginClass the plugin class + * @return the plugin name */ @Deprecated public static String getPluginName(Class> pluginClass) { @@ -514,8 +519,10 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser } /** - * Check if this plugin depends on the given plugin. - *
+ * Check if this plugin depends on the given plugin + * + * @param plugin the plugin + * @return true if this plugin depends on the given plugin */ public boolean dependsUpon(Plugin plugin) { for (Class> c : getList(pluginDescription.getServicesRequired(), @@ -791,8 +798,8 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser } /** - * Override this method if the plugin needs to cancel the closing of - * the domain object. + * Override this method if the plugin needs to cancel the closing of the domain object + * @param dObj the domain object * @return false if the domain object should NOT be closed */ protected boolean canCloseDomainObject(DomainObject dObj) { @@ -826,7 +833,11 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser } /** - * Close the plugin. + * Close the plugin. This is when the plugin should release resources, such as those from + * other services. This method should not close resources being used by others (that should + * happen in dispose()). + * + *
This method will be called before {@link #dispose()}. */ protected void close() { // do nothing by default; subclasses should override as needed @@ -886,6 +897,7 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser * Returns an object containing the plugin's state as needed to restore itself after an undo * or redo operation. Plugins should override this method if they have special undo/redo handling. * @param domainObject the object that is about to or has had undoable changes made to it. + * @return the state object */ public Object getUndoRedoState(DomainObject domainObject) { // do nothing by default; subclasses should override as needed