How to avoid a QGIS crash when it is appended a symbol layer in a symbol?

المشرف العام

Administrator
طاقم الإدارة
When I run the next code at the Python Console of QGIS with a line vector layer:

symbol1 = QgsLineSymbolV2.createSimple({'penstyle':'solid', 'color':'black', 'width':'3' })symbol2 = QgsLineSymbolV2.createSimple({'penstyle':'dash', 'color':'white', 'width':'0', 'customdash':'8;4', 'use_custom_dash': '1' })route = iface.activeLayer()renderer = route.rendererV2()type1 = symbol1.type()type2 = symbol2.type()print "Is Symbol Layer Compatible?", symbol1.isSymbolLayerCompatible(type2)#Create Symbol Layerssymbol_layer1 = symbol1.symbolLayer(0)symbol_layer2 = symbol2.symbolLayer(0)#Append Symbol Layer 2 to symbol1 (now with two Symbol Layers)symbol1.appendSymbolLayer(symbol_layer2)renderer.setSymbol(symbol1)route.triggerRepaint()iface.legendInterface().refreshLayerSymbology(route)I got the following result:



indicating that the symbol2 (QgsLineSymbolV2 class), as Symbol Layer (symbol_layer2 belongs to QgsLineSymbolLayerV2 class), it was correctly appending to symbol1. However, when this code is ran again, QGIS crashes and it closes all windows. This behavior doesn't appear if the symbol has only one Symbol Layer; when it is commented, at the first execution time, the line with this instruction:

symbol1.appendSymbolLayer(symbol_layer2)).

How can I prevent the second time QGIS crash when I am using a symbol with 2 or more Symbol Layers?



أكثر...
 
أعلى