From cc9c7897602887633eb59486a1aa65df0c566982 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Sun, 18 Oct 2015 00:20:07 +0200 Subject: [PATCH] avoid on duplicate user functions (fixes #13579) --- python/core/__init__.py | 6 +++++- python/user.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/core/__init__.py b/python/core/__init__.py index 5506f81bceb..7e23f2374c7 100644 --- a/python/core/__init__.py +++ b/python/core/__init__.py @@ -1,6 +1,7 @@ import inspect import string from qgis._core import * +from PyQt4.QtCore import QCoreApplication def register_function(function, arg_count, group, usesgeometry=False, **kwargs): @@ -66,7 +67,10 @@ def register_function(function, arg_count, group, usesgeometry=False, **kwargs): register = kwargs.get('register', True) if register and QgsExpression.isFunctionName(name): if not QgsExpression.unregisterFunction(name): - raise TypeError("Unable to unregister function") + msgtitle = QCoreApplication.translate("UserExpressions", "User expressions") + msg = QCoreApplication.translate("UserExpressions", "The user expression {0} already exists and could not be unregistered.").format(name) + QgsMessageLog.logMessage(msg + "\n", msgtitle, QgsMessageLog.WARNING) + return None function.__name__ = name helptext = helptemplate.safe_substitute(name=name, doc=helptext) diff --git a/python/user.py b/python/user.py index 132e39250be..646449bb618 100644 --- a/python/user.py +++ b/python/user.py @@ -68,5 +68,5 @@ try: 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 + # But for now it's not the end of the world if it doesn't load the first time pass