Skip to content

Commit e7a981c

Browse files
committedNov 26, 2015
avoid on duplicate user functions (fixes #13579)
(backports from commit cc9c789)
1 parent 945187c commit e7a981c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎python/core/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
import string
33
from qgis._core import *
4+
from PyQt4.QtCore import QCoreApplication
45

56
def register_function(function, arg_count, group, usesgeometry=False, **kwargs):
67
"""
@@ -66,7 +67,10 @@ def func(self, values, feature, parent):
6667
register = kwargs.get('register', True)
6768
if register and QgsExpression.isFunctionName(name):
6869
if not QgsExpression.unregisterFunction(name):
69-
raise TypeError("Unable to unregister function")
70+
msgtitle = QCoreApplication.translate("UserExpressions", "User expressions")
71+
msg = QCoreApplication.translate("UserExpressions", "The user expression {0} already exists and could not be unregistered.").format(name)
72+
QgsMessageLog.logMessage(msg + "\n", msgtitle, QgsMessageLog.WARNING)
73+
return None
7074

7175
function.__name__ = name
7276
helptext = helptemplate.safe_substitute(name=name, doc=helptext)

0 commit comments

Comments
 (0)
Please sign in to comment.