diff --git a/build.py b/build.py index 407210272..85f6edf00 100644 --- a/build.py +++ b/build.py @@ -74,7 +74,6 @@ class Build: self.pkgconfig_gens = [] self.install_script = None self.install_dirs = [] - self.modules = {} def has_language(self, language): for i in self.compilers: diff --git a/coredata.py b/coredata.py index 15c327ad7..11410af00 100644 --- a/coredata.py +++ b/coredata.py @@ -54,6 +54,7 @@ class CoreData(): self.deps = {} self.ext_progs = {} self.ext_libs = {} + self.modules = {} def get_builtin_option(self, optname): if optname == 'type': diff --git a/interpreter.py b/interpreter.py index 37b37bbbc..bda466dd0 100644 --- a/interpreter.py +++ b/interpreter.py @@ -600,15 +600,15 @@ class ModuleState: pass class ModuleHolder(InterpreterObject): - def __init__(self, modname, interpreter): + def __init__(self, modname, module, interpreter): InterpreterObject.__init__(self) self.modname = modname - self.m = importlib.import_module('modules.' + modname).initialize() + self.held_object = module self.interpreter = interpreter def method_call(self, method_name, args, kwargs): try: - fn = getattr(self.m, method_name) + fn = getattr(self.held_object, method_name) except AttributeError: raise InvalidArguments('Module %s does not have method %s.' % (self.modname, method_name)) state = ModuleState() @@ -735,7 +735,6 @@ class Interpreter(): self.global_args_frozen = False self.subprojects = {} self.subproject_stack = [] - self.modules = {} def build_func_dict(self): self.funcs = {'project' : self.func_project, @@ -865,11 +864,10 @@ class Interpreter(): modname = args[0] if not isinstance(modname, str): raise InvalidCode('Argument to import was not a string') - if not modname in self.modules: - mh = mh = ModuleHolder(modname, self) - self.modules[modname] = mh - self.build.modules[modname] = mh.m - return self.modules[modname] + if not modname in self.environment.coredata.modules: + module = importlib.import_module('modules.' + modname).initialize() + self.environment.coredata.modules[modname] = module + return ModuleHolder(modname, self.environment.coredata.modules[modname], self) def set_variable(self, varname, variable): if variable is None: diff --git a/test cases/frameworks/4 qt5/meson.build b/test cases/frameworks/4 qt5/meson.build index dd57ef543..95423312b 100644 --- a/test cases/frameworks/4 qt5/meson.build +++ b/test cases/frameworks/4 qt5/meson.build @@ -10,7 +10,7 @@ endif q5exe = executable('qt5app', sources : ['main.cpp', 'mainWindow.cpp', # Sources that don't need preprocessing. qt5.preprocess(moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. - ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. + ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. qresources : 'stuff.qrc', # Resource file for rcc compiler. )], dependencies : qt5dep)