Fix set dashes for line collections

Rebased version of #1704 targetting v1.2.x and with a unit test. It fixes #1701.