Commit 88d1d4fd authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files
parent 719a18a8
......@@ -279,20 +279,20 @@ def registerQgsExpressionFunctions():
QGIS_FUNCTION_INSTANCES[func.name()] = func
if QgsExpression.isFunctionName(func.name()):
if not QgsExpression.unregisterFunction(func.name()):
msgtitle = QCoreApplication.translate("UserExpressions", "User expressions")
msg = QCoreApplication.translate("UserExpressions",
"User expression {0} already exists and "
"can not be unregistered.").format(func.name)
QgsMessageLog.logMessage(msg + "\n", msgtitle, Qgis.Warning)
QgsMessageLog.logMessage(msg + "\n", level=Qgis.Warning)
return None
if QgsExpression.registerFunction(func):
QgsMessageLog.logMessage(f'Registered {func.name()}', level=Qgis.Info)
else:
QgsExpression.registerFunction(func)
QgsMessageLog.logMessage(f'Failed to register {func.name()}', level=Qgis.Warning)
def unregisterQgsExpressionFunctions():
msgtitle = QCoreApplication.translate("UserExpressions", "User expressions")
for name, func in QGIS_FUNCTION_INSTANCES.items():
if QgsExpression.unregisterFunction(name):
QgsMessageLog.logMessage(f'Unregistered {name}', msgtitle, Qgis.Info)
QgsMessageLog.logMessage(f'Unregistered {name}', level=Qgis.Info)
else:
QgsMessageLog.logMessage(f'Unable to unregister {name}', msgtitle, Qgis.Warning)
\ No newline at end of file
QgsMessageLog.logMessage(f'Unable to unregister {name}',level=Qgis.Warning)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment