I make a little plugin, and I get some strange result.
The program now mirror the "Layers Panel". When I add or delete layers from the Panel the `QListWidget` module get the name of layers.
I connect the function to the `legendLayersAdded` and to `layersRemoved` SIGNAL.

THE PROBLEM:
The add part is ok, and if I remove ONE layer that's fine to. But if I remove multiple layers, the widget get back the rest of layers name multiple times (count of removed layers).
I's like the signal calls the function recursive!?
I tried whit  layerWasRemoved Signal and the result was the same
I made a video of it becouse it hard to explained. 

[https://www.youtube.com/watch?v=NuLtANtlLtE&feature=youtu.be]

Here is the code:

    def ablak(self):
    layers = [] 
    self.dockwidget.telepules_kezelo.clear()
    layers = self.iface.legendInterface().layers()
    print "Befor" # Befor layer list
    print layers # Layer list "from Layers Panel"
    print "After" # After layer list
    i = 0 # Just a counter for debubing
    lista = self.dockwidget.telepules_kezelo
    for layer in layers:
        print layer.name()
        lista.addItem(layer.name())
        i = i+1
        print i # Counter for debuging
    layers = []

    
    QgsMapLayerRegistry.instance().legendLayersAdded.connect(self.ablak)

    QgsMapLayerRegistry.instance().layersRemoved.connect(self.ablak)


I fade out the problem whit transfer the `self.dockwidget.telepules_kezelo.clear()` line after the `Print After` line. And it's working fine, but I really fluster about it..

Any help will be welcome.