Skip to content
Permalink
Browse files

avoid on duplicate user functions (fixes #13579)

(backports from commit cc9c789)
  • Loading branch information
jef-n committed Nov 26, 2015
1 parent 945187c commit e7a981cc95652c1fc9c85cdec262440344476168
Showing with 5 additions and 1 deletion.
  1. +5 −1 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 func(self, values, feature, parent):
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)

0 comments on commit e7a981c

Please sign in to comment.
You can’t perform that action at this time.