<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class="">Just found out that this is not addMapLayer that remove the variables but 'layer.loadNamedStyle'</div><div class=""><br class=""></div><div class="">Print layer.customProperty('variableNames') just before calling 'layer.loadNamedStyle' show variables</div><div class="">Print layer.customProperty('variableNames') just after the call :  empty list</div><div class=""><br class=""></div><div class="">Reproduced in the python console:</div><div class=""><br class=""></div><div class=""><div class="">>>> QgsExpressionContextUtils.setLayerVariable(layer,'FOO','BAR')</div><div class=""><div class="">>>> layer.customProperty('variableNames')</div><div class="">['FOO']</div></div><div class="">>>> layer.loadNamedStyle('mystyle.qml')</div><div class="">('', True)</div><div class="">>>> layer.customProperty('variableNames')</div></div><div class="">[]</div><div class=""><br class=""></div><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div></div></div><div><blockquote type="cite" class=""><div class="">Le 20 juin 2018 à 18:13, David Marteau <<a href="mailto:dmarteau@3liz.com" class="">dmarteau@3liz.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi</div><div class=""><br class=""></div><div class="">I'm trying to set custom layers variables from processing using  QgsExpressionContextUtils.setLayerVariables to destination layers , I have found that those variables does not appear in </div><div class="">Qgis. </div><div class=""><br class=""></div><div class="">I have found that when the layer is inserted in the current project (<a href="https://github.com/qgis/QGIS/blob/master/python/plugins/processing/gui/Postprocessing.py#L81" class="">https://github.com/qgis/QGIS/blob/master/python/plugins/processing/gui/Postprocessing.py#L81</a>) the layer variables are removed - Checking existence of the variable before</div><div class="">and after the call of 'addMaperLayer' shows that layer variables are removed from custom properties.</div><div class=""><br class=""></div><div class="">I cannot tell if this is a bug or not because it seems that the removal may occurs in some signal handler. So if somebody has some clues to where to look, I will be grateful.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px;" class=""><!--StartFragment-->Qgis version: 3.0.3-Girona<!--EndFragment--></div></div><div class=""><br class=""></div><div class="">David</div></div></div></blockquote></div><br class=""></body></html>