Skip to content

GetImageThumbnailAsync null reference exception #4

@Swifter

Description

@Swifter

photoeditor_exception_when_scrolling

GetTumbnailAsync sometimes returns NULL, which your code does not account for. Do this instead:

    IAsyncOperation<BitmapImage> Photo::GetImageThumbnailAsync() const
    {
        auto thumbnail = co_await m_imageFile.GetThumbnailAsync(FileProperties::ThumbnailMode::PicturesView);
        BitmapImage bitmapImage{};

		// fix for when thumbnail is NULL
		if (NULL != thumbnail)
		{
			bitmapImage.SetSource(thumbnail);
			thumbnail.Close();
		}

        co_return bitmapImage;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions