Skip to content

Commit

Permalink
Fix crash on user.py import of expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 26, 2015
1 parent ab0aa04 commit 2112128
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions python/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,25 @@ def load_user_expressions(path):
if not os.path.exists(initfile):
open(initfile, "w").close()

import site
reload(site)
try:
import expressions

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
\"\"\"
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 *
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def func(value1, feature, parent):
return value1
"""
@qgsfunction(args='auto', group='Custom')
def func(value1, feature, parent):
return value1
"""
except ImportError:
# We get a import error and crash for some reason even if we make the expressions package
# TODO Fix the crash on first load with no expressions folder
# But for now it's not the end of the world if it doesn't laod the first time
pass

0 comments on commit 2112128

Please sign in to comment.