I have several tools working with QGIS rubberband before activating my new map tool i want to make sure there is nothing on rubberband previously up to QGIS 3.2 I was able to clean the rubberband via the following code
rbs = [ i for i in canvas.scene().items() if issubclass(type(i), qgis._gui.QgsRubberBand) ]
if len(rbs)>0:
for rb in rbs:
if rb in canvas.scene().items():
canvas.scene().removeItem(rb)
This code no longer works(as QGIS adds some default rubberband and when I try this QGIS crashes now the question is how to have similar functionality (cleaning map canvas from all rubberbands before starting)