Unregister StelObjectModule from StelObjectMgr

Asked by Emmanuel

Is it possible to unregister a custom StelObjectModule from the StelObjectMgr after it has been registered?
I haven't found a way to do it through the StelObjectMgr 0.12.0 API, nor does StelModuleMgr::unloadModule() take care of checking whether the module is also registered with the StelObjectMgr, and in that case also remove it from the StelObjectMgr.

Question information

Language:
English Edit question
Status:
Solved
For:
Stellarium Edit question
Assignee:
No assignee Edit question
Solved by:
Emmanuel
Solved:
Last query:
Last reply:
Revision history for this message
Matthew Gates (matthew-porpoisehead) said :
#1

Yes, it's possible, although at present many of the modules are not
safe to unload, which can lead to a crash. There is some work to do
before all modules become runtime unloadabe. Once this is done, the
plugins list should be a little more usable - instead of a "load at
startup" option for each, they will just be load/unload.

There was a branch a little while ago to do this, but it's very out of
date, and I didn't make much progress so the task will probably have
to be re-started from a more recent trunk version.

Specific things which need watching for:

- gui elements should be closed and properly de-allocated
- objects which have started timers should destroy them properly
- etc.

M

On 31 March 2013 07:35, Emmanuel <email address hidden> wrote:
> New question #225542 on Stellarium:
> https://answers.launchpad.net/stellarium/+question/225542
>
> Is it possible to unregister a custom StelObjectModule from the StelObjectMgr after it has been registered?
> I haven't found a way to do it through the StelObjectMgr 0.12.0 API, nor does StelModuleMgr::unloadModule() take care of checking whether the module is also registered with the StelObjectMgr, and in that case also remove it from the StelObjectMgr.
>
>
>
> --
> You received this question notification because you are an answer
> contact for Stellarium.

Revision history for this message
Emmanuel (hacker-emmanuel) said :
#2

Thanks for your answer but I still don't see how to unregister an object module.

The context is in writing a "master module" that can in it's turn load and unload other custom (sub-)modules to the StelModuleMgr, and possibly register some of these sub-modules that happen to also be "object modules", to the StelObjectMgr.

=> How then can the "master module" unload sub-modules (this is easy) _and_ unregister "object modules" (have them cleanly removed from QList<StelObjectModule*> StelObjectMgr::objectsModule)?

I found nowhere in the code that StelObjectMgr::objectsModule is ever explicitly depopulated but I may have missed something, if not, this might be grounds for a bug/feature report in view of supporting clean unloading of (object-)modules.

Now if it's not currently possible to cleanly unregister an object-module, a work around would be that the master module not register the sub-modules to stellarium but manages itself the sub-modules and forward itself function calls (draw, searchAround, etc.) from stellarium to the sub-modules.

Revision history for this message
Emmanuel (hacker-emmanuel) said :
#3

The ideal solution would be that function
  void StelObjectMgr::registerStelObjectMgr(StelObjectModule* mgr)
has an opposite
  void StelObjectMgr::unregisterStelObjectMgr(StelObjectModule* mgr)

In the meanwhile it's possible for a third-party plugin to do it by directly accessing private member QList<StelObjectModule*> StelObjectMgr::objectsModule using one a various techniques described on http://www.gotw.ca/gotw/076.htm