When reloading plugins delete top level module too
importlib.reload() has some differences in semantics from import which leads to some plugins not reloading correctly
This commit is contained in:
parent
34a0d1947a
commit
8170e2f57c
|
@ -113,17 +113,10 @@ def LoadPluginModule(Dirname, ModuleName, FileName):
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
try:
|
|
||||||
from importlib import reload # Python 3.4 or above
|
|
||||||
except ImportError:
|
|
||||||
from imp import reload # Python <3.4; harmless alias on 2.7
|
|
||||||
|
|
||||||
global NOT_LOADED_WIZARDS
|
global NOT_LOADED_WIZARDS
|
||||||
global FULL_BACK_TRACE
|
global FULL_BACK_TRACE
|
||||||
global KICAD_PLUGINS
|
global KICAD_PLUGINS
|
||||||
|
|
||||||
top_level_modules = KICAD_PLUGINS.keys()
|
|
||||||
|
|
||||||
try: # If there is an error loading the script, skip it
|
try: # If there is an error loading the script, skip it
|
||||||
|
|
||||||
module_filename = os.path.join( Dirname, FileName )
|
module_filename = os.path.join( Dirname, FileName )
|
||||||
|
@ -134,14 +127,11 @@ def LoadPluginModule(Dirname, ModuleName, FileName):
|
||||||
plugin = KICAD_PLUGINS[ModuleName]
|
plugin = KICAD_PLUGINS[ModuleName]
|
||||||
|
|
||||||
for dependency in plugin["dependencies"]:
|
for dependency in plugin["dependencies"]:
|
||||||
if dependency in sys.modules and dependency not in top_level_modules:
|
if dependency in sys.modules:
|
||||||
del sys.modules[dependency]
|
del sys.modules[dependency]
|
||||||
|
|
||||||
mods_before = set( sys.modules )
|
mods_before = set( sys.modules )
|
||||||
|
|
||||||
mod = reload( plugin["ModuleName"] )
|
|
||||||
|
|
||||||
else:
|
|
||||||
if sys.version_info >= (3,0,0):
|
if sys.version_info >= (3,0,0):
|
||||||
import importlib
|
import importlib
|
||||||
mod = importlib.import_module( ModuleName )
|
mod = importlib.import_module( ModuleName )
|
||||||
|
|
Loading…
Reference in New Issue