Skip to content

Fix rightBeforeLoadingScene method overloading#585

Open
alxbilger wants to merge 2 commits intosofa-framework:masterfrom
alxbilger:rightBeforeLoadingScene
Open

Fix rightBeforeLoadingScene method overloading#585
alxbilger wants to merge 2 commits intosofa-framework:masterfrom
alxbilger:rightBeforeLoadingScene

Conversation

@alxbilger
Copy link
Contributor

A code smell.

SceneLoaderListerner derives from SceneLoader::Listener. The class SceneLoader::Listener has a method rightBeforeLoadingScene accepting a SceneLoader*. But SceneLoaderListerner does not overload it. Instead, it define another method rightBeforeLoadingScene with a different signature. Even if it is intentional, I did not find any call of this signature. So my guess is a wrong overriding of the base method.

However, now that it's properly implemented, I don't know the effects of this call...

@damienmarchal
Copy link
Contributor

damienmarchal commented Feb 27, 2026

The line your are pointing are rather old and calls that code (un SofaRuntime/init.py):

def unloadModules():
    """ Call this function to unload python modules and to force their reload

        (useful to take into account their eventual modifications since
        their last import).
    """
    global __SofaPythonEnvironment_importedModules__
    toremove = [name for name in sys.modules if not name in __SofaPythonEnvironment_importedModules__ and not name in __SofaPythonEnvironment_modulesExcludedFromReload ]
    for name in toremove:
        del(sys.modules[name]) # unload it

I think this was implemented to force the reloading of python modules when loading a new python scene.
The underlying idea is that we don't want the loaded module to be persistent between different scenes.

The hot-reload mechanism as not been really updated since Sofapython2 and it would be worth some cleaning/refreshing.

Co-authored-by: Damien Marchal <damien.marchal@univ-lille1.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants