problem solved: label layers do not have styles. Check whether the layer is labellayer before applying style.