Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetImageThumbnailAsync null reference exception #4

Open
Swifter opened this issue Sep 25, 2018 · 1 comment
Open

GetImageThumbnailAsync null reference exception #4

Swifter opened this issue Sep 25, 2018 · 1 comment

Comments

@Swifter
Copy link

Swifter commented Sep 25, 2018

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;
    }
@Swifter
Copy link
Author

Swifter commented Sep 3, 2020

GetThumbnailAsync returns NULL when you attempt to open a file that looks to the file system like it might be a picture (it has .jpg or .png extension), but is actually not (ex: it is a text file someone renamed to .jpg).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant