Skip to content
  • Dmitry Kazakov's avatar
    Possible fix for the artifacts when using the line tool · 6d87f894
    Dmitry Kazakov authored
    There was a theoretical race condition possible in
    KisAsyncMerger::setupProjection:
    
    Preconditions:
    
    1) The image has only one layer with fully transparent default pixel
       (to trigget tryOblidgeChild mechanism)
    
    Mecanics of the issue:
    
    1) KisAsyncMerger requests currentLeaf->parent()->original(), which points
       to the projection() of the only child layer (which equals to
       its paintDevice().
    
    2) KisAsyncMerger thread sleeps
    
    3) Some other thread starts an indirect painting stroke over this
       layer, basically changing projection() of the layer to be separate
       from its paintDevice()
    
    4) KisAsyncMerger thread wakes up
    
    5) The condition `parentOriginal != currentLeaf->projection()` succeeds
       because parentOriginal still points to the layer's paintDevice
    
    6) KisAsyncMerger starts to write into paint layer's paint device,
       which breaks its undo history.
    
    Lots of thanks go to freyalupen for debugging this issue locally and
    providing the valuable debugging info.
    
    CCBUG:460461
    6d87f894