on xenial help sign in
Respect pre-set import paths and prevent segfault in startShell.
commit5e9076928435bbfc6d31e768e8c866048aabc9ef authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 4 Oct 2013, 17:20 (13 years ago) parentb2a6f28
2 files changed+17−7
main.cpp+7−3 tests/autopilot/unity8/shell/tests/__init__.py+10−4
main.cpp+7−3
@@ -160,10 +160,14 @@ int startShell(int argc, const char** argv, void* server)
160160 prependImportPaths(view->engine(), ::overrideImportPaths());
161161 appendImportPaths(view->engine(), ::fallbackImportPaths());
162162
163− QStringList importPath = view->engine()->importPathList().filter("qt5/imports");
164163 if (isUbuntuMirServer) {
165− importPath.first().append("/Unity-Mir");
166− view->engine()->addImportPath(importPath.first());
164+ QStringList importPath = view->engine()->importPathList().filter("qt5/imports");
165+ if (!importPath.isEmpty()) {
166+ importPath.first().append("/Unity-Mir");
167+ view->engine()->addImportPath(importPath.first());
168+ } else {
169+ qDebug() << "unable to patch import path";
170+ }
167171 }
168172
169173 view->setSource(source);
tests/autopilot/unity8/shell/tests/__init__.py+10−4
@@ -183,10 +183,14 @@ class UnityTestCase(AutopilotTestCase):
183183 def patch_lightdm_mock(self, mock_type='single'):
184184 self._lightdm_mock_type = mock_type
185185 logger.info("Setting up LightDM mock type '%s'", mock_type)
186− new_ld_library_path = "%s:%s" % (
186+ new_ld_library_path = [
187187 get_default_extra_mock_libraries(),
188188 self._get_lightdm_mock_path(mock_type)
189− )
189+ ]
190+ if os.getenv('LD_LIBRARY_PATH') is not None:
191+ new_ld_library_path.insert(0, os.getenv('LD_LIBRARY_PATH'))
192+
193+ new_ld_library_path = ':'.join(new_ld_library_path)
190194 logger.info("New library path: %s", new_ld_library_path)
191195
192196 self.patch_environment('LD_LIBRARY_PATH', new_ld_library_path)
@@ -205,8 +209,10 @@ class UnityTestCase(AutopilotTestCase):
205209 return lightdm_mock_path
206210
207211 def _setup_extra_mock_environment_patch(self):
208− mocks_library_path = get_mocks_library_path()
209− self.patch_environment('QML2_IMPORT_PATH', mocks_library_path)
212+ qml_import_path = [get_mocks_library_path()]
213+ if os.getenv('QML2_IMPORT_PATH') is not None:
214+ qml_import_path.insert(0, os.getenv('QML2_IMPORT_PATH'))
215+ self.patch_environment('QML2_IMPORT_PATH', ':'.join(mocks_library_path))
210216
211217 def _set_proxy(self, proxy):
212218 """Keep a copy of the proxy object, so we can use it to get common