CRhinoPlugIn::OnUnloadPlugIn()

Hi all, as a plug-in developer, I experience issues on Rhino 6 if my plugin is working and the user presses [x] button of Rhino 6 and closes Rhino. At this moment according to the SDk the only way for the plugin to understand that Rhino is exiting is:

// Description:
  //    Called one time when plug-in is about to be unloaded. By this time,
  //    Rhino's mainframe window has been destroyed, and some of the SDK
  //    managers have been deleted. There is also no active document or active 
  //    view at this time. Thus, you should only be manipulating your own objects.
  //    or tools here.
  virtual void OnUnloadPlugIn();

The problem is that at this moment, the plugin may still need Rhino to be fully working to make calculations, queries or whatever to the Rhino app. Currently it is too late for the plugin to do anything.

Proposal - can you have another function like OnRhinoIsExiting() or PreDestroy() or RhinoIsAboutToExit() where the plugin can tidy up everything dependent on Rhino core/classes.
Or simply unload the plugins before shut down the whole framework.

(Just to mention that this problem doesn’t exists on Rhino 5)

Regards
Kostadin

2 Likes

+1.

RhinoCommon/Grasshopper has become an application development platform and therefore we need more hooks to events fireing before and after major events,

// Rolf

Hi @kostadin,

You might consider overriding CRhinoPlugIn::OnSaveAllSettings.

  // Description:
  //    The Rhino plug-in manager will call this method when Rhino is preparing
  //    to close. At this point, the Rhino SDK should still be completely
  //    accessible.
  //
  // See Also:
  //    CWinApp::SaveAllSettings
  //    CRhinoPlugIn::OnLoadPlugIn()
  virtual void OnSaveAllSettings();

rhinoSdkPlugIn.h has the details.

– Dale