Fix tail-artifacts when painting with a Pixel brush on a transparency mask
In the end of the stroke indirect device is merged into the main selection
used a lock help. We should synchronize with this lock to ensure there is
no race condition between reading two extents: from the main selection and
indirect target.
Note: there is still another bug when with Quick Brush, but I'll put it
under a separate bugreport.
BUG:394438
(cherry picked from commit 25801542f2294268ec0a5174e4195375ba460571)