• Toni Barzic's avatar
    Fix holding space image lifetime issues · eff5ce7f
    Toni Barzic authored
    HoldingSpaceImage's image source has a pointer to the HoldingSpaceImage,
    so it can notify it that new image representation has been loaded.
    Image source is owned by the image itself, and may outlive the
    associated HoldingSpaceItem, which owns HoldingSpaceImage. If the
    thumbnail generation for the item finishes after the item has been
    destroyed, the holding space image source may attempt to access the
    HoldingSpaceImage object after destruction.
    To fix this, pass a weak pointer to HoldingSpaceImage source, so it can
    verify the HoldingSpaceImage is still around before notifying it that
    the image has changed.
    
    HoldingSpcareTrayIconPreview contents image had a similar issue where it
    was getting the item image from the item ptr. This was done in
    GetImageForScale, which may get called as long as the associated image
    skia is around, which doesn't guarantee that the item has not already
    been deleted - instead, have the contents image use the image skia
    directly.
    
    BUG=1156776
    
    Change-Id: I6e6c6d14ed5a25739e8b4366225f29dfa8706c8e
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587655Reviewed-by: default avatarDavid Black <dmblack@google.com>
    Commit-Queue: Toni Baržić <tbarzic@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#836402}
    eff5ce7f
holding_space_image.cc 3.21 KB