I'm trying to copy symbol of a certain polygon layer to multiple layers (also polygon) in project at once with a condition in cycle. But as soon as the script start to modify a symbol of the second layer, QGIS crashes.
layer = iface.activeLayer()
copyrend = layer.renderer()
for layer in QgsProject.instance().mapLayers().values():
if layer.name().find("some_condition_in_name") != -1:
layer.renderer().setSymbol(copyrend.symbol())
layer.triggerRepaint()
Doing it without a cycle for a single layer works fine, but doing it for the whole project (~1000 layers) concludes in a crash. What can I do to avoid this?
If I don't use a ".triggerRepaint()" for every layer, QGIS will not crash until I'm trying to do something with a layers that has a changed symbol.