I have a stand-alone pyqgis application that can display vector data. I have implemented a routine that sets layer's renderer as below:
def set_sym(layer):
symbol = QgsMarkerSymbolV2.createSimple({})
symbol_layer = QgsSimpleMarkerSymbolLayerV2()
symbol_layer.setColor(QColor(0, 0, 0, 255))
symbol_layer.setName('circle')
symbol_layer.setSize(1.0)
symbol.appendSymbolLayer(symbol_layer)
renderer = QgsSingleSymbolRendererV2(symbol)
layer.setRendererV2(renderer)
It works. However, if I call it a second time on a layer, then immediately go to exit the program, it hangs & I have to kill the background python process to get out of it. I've already checked that the newly created renderer and the layer.rendererV2() are different and their symbol() are also different (I mean the memory addresses are different). So, it makes me think that the setRendererV2() routine is not replacing the renderer cleanly, hence hanging the program upon quitting right after the second call on the same layer. Please let me know if there is something I missed that caused this.
renderer = QgsSingleSymbolRendererV2(symbol)
call achieves that, right?