Skip to content
Permalink
Browse files
Merge pull request #2096 from slarosa/fix_crash_user_expressions
[user expression] fixes #12852
  • Loading branch information
jef-n committed May 30, 2015
2 parents 51bd0b2 + f7401c9 commit 96b535b279fe0dba955a64e3e7a1011a92e9c2b3
Showing with 12 additions and 3 deletions.
  1. +12 −3 python/user.py
@@ -1,8 +1,10 @@
import os
import sys
import glob
import traceback

from qgis.core import QgsApplication
from PyQt4.QtCore import QCoreApplication
from qgis.core import QgsApplication, QgsMessageLog

def load_user_expressions(path):
"""
@@ -14,9 +16,16 @@ def load_user_expressions(path):
for name in names:
if name == "__init__":
continue
# As user expression functions should be registed with qgsfunction
# As user expression functions should be registered with qgsfunction
# just importing the file is enough to get it to load the functions into QGIS
__import__("expressions.{0}".format(name), locals(), globals())
try:
__import__("expressions.{0}".format(name), locals(), globals())
except:
error = traceback.format_exc()
msgtitle = QCoreApplication.translate("UserExpressions", "User expressions")
msg = QCoreApplication.translate("UserExpressions",
"The user expression {0} is not valid".format(name))
QgsMessageLog.logMessage(msg +"\n"+ error, msgtitle, QgsMessageLog.WARNING)


userpythonhome = os.path.join(QgsApplication.qgisSettingsDirPath(), "python")

0 comments on commit 96b535b

Please sign in to comment.