Bug report #12340
using --configpath on new empty dir raises Python error + subsequest segfault
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Nathan Woodrow | ||
Category: | Expressions | ||
Affected QGIS version: | 2.8.1 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | fixed/implemented |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 20516 |
Description
Paolo asked for it on the dev list, I can confirm:
- create a new dir:
mkdir /tmp/t1 - start qgis using --configpath
qgis --configpath /tmp/t1
QGIS will generate the following python error and crash after that:
Couldn't load qgis.user. Python support will be disabled. Traceback (most recent call last): File "", line 1, in File "/home/richard/apps/qgis/master/debug/share/qgis/python/qgis/utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/home/richard/apps/qgis/master/debug/share/qgis/python/qgis/user.py", line 39, in import expressions File "/home/richard/apps/qgis/master/debug/share/qgis/python/qgis/utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named expressions
NOTE: starting QGIS again using same dir is now ok...
Associated revisions
Fix #12340 - Reload site to pick up new expressions package
History
#1 Updated by Paolo Cavallini almost 10 years ago
Thanks Richard.
#2 Updated by Jürgen Fischer almost 10 years ago
- Assignee set to Nathan Woodrow
expressions/__init__.py
is created when it's not available - but the freshly created module can apparently not be initially loaded via "import expressions".
#3 Updated by Jürgen Fischer almost 10 years ago
- Category changed from Browser to Expressions
#4 Updated by Nathan Woodrow over 9 years ago
- Status changed from Open to Closed
Fixed in changeset 738838acd4ed023e2a181fba4707e6425223315f.
#5 Updated by Nathan Woodrow over 9 years ago
- Resolution set to fixed/implemented
Should hopefully be fixed now. Not sure if doing reload(site) is the best solution but it does work and doesn't seem to mess anything up.
#6 Updated by Richard Duivenvoorde over 9 years ago
- Status changed from Closed to Reopened
Reopening this one, because this still occurs with me.
If I surround the import expressions part with a try/catch, and write some warning, then at least I do not have a segfault the first time:
import site reload(site) try: # try this import, but will fail when this is a fresh configuration directory # eg when starting QGIS with: "qgis --configpath /tmp/foo " import expressions expressions.load = load_user_expressions expressions.load(expressionspath) expressions.template = """\\"\\"\\" Define new functions using @qgsfunction. feature and parent must always be the last args. Use args=-1 to pass a list of values as arguments \\"\\"\\" from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def func(value1, feature, parent): return value1 """ except: msgtitle = QCoreApplication.translate("UserExpressions", "User expressions") msg = QCoreApplication.translate("UserExpressions", "Unable to load Expressions... New Settings/Config?") QgsMessageLog.logMessage(msg, msgtitle, QgsMessageLog.WARNING)
Let me know if this is fix or need a pull request
#7 Updated by Richard Duivenvoorde over 9 years ago
@nathan:
is 2112128 the final fix? So we can close this one?
#8 Updated by Nathan Woodrow over 9 years ago
- Status changed from Reopened to Closed
Yep. Seems it was close to what you had too. Sorry I didn't even check.