mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-07 00:03:52 -05:00
avoid on duplicate user functions (fixes #13579)
This commit is contained in:
parent
6496bc4955
commit
cc9c789760
@ -1,6 +1,7 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import string
|
import string
|
||||||
from qgis._core import *
|
from qgis._core import *
|
||||||
|
from PyQt4.QtCore import QCoreApplication
|
||||||
|
|
||||||
|
|
||||||
def register_function(function, arg_count, group, usesgeometry=False, **kwargs):
|
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)
|
register = kwargs.get('register', True)
|
||||||
if register and QgsExpression.isFunctionName(name):
|
if register and QgsExpression.isFunctionName(name):
|
||||||
if not QgsExpression.unregisterFunction(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
|
function.__name__ = name
|
||||||
helptext = helptemplate.safe_substitute(name=name, doc=helptext)
|
helptext = helptemplate.safe_substitute(name=name, doc=helptext)
|
||||||
|
|||||||
@ -68,5 +68,5 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
# We get a import error and crash for some reason even if we make the expressions package
|
# 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
|
# 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
|
pass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user