back port 6576105 from cairocanvas as fix for data loss/file deletion