Skip to content

Conversation

mstv
Copy link
Member

@mstv mstv commented Mar 22, 2025

Fixes #12269

Proposed changes

FileViewer: Render only the first frame of an animated image in order to avoid exception in PictureBox.WndProc

Screenshots

Before

first frame, then red frame and cross

After

first frame

Test methodology

  • manual

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@mstv mstv self-assigned this Mar 22, 2025
@gerhardol
Copy link
Member

Any example of a file that triggers this problem?

if (image.GetFrameCount(frameDimension) > 1)
{
image.SelectActiveFrame(frameDimension, 0);
image = new Bitmap(image);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we might be leaking a handle here...

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test for this?

@mstv
Copy link
Member Author

mstv commented Mar 23, 2025

Is it possible to add a test for this?

This would require integration testing. Integration test cases are too expensive and too difficult to setup stably. It is not worth IMO, specifically for this workaround for a bug in the platform, which the debugger even cannot catch.

in order to avoid exception in PictureBox.WndProc

Refs: gitextensions#12274
@mstv mstv force-pushed the fix/animated_gif branch from 05a6017 to e7c9a40 Compare March 31, 2025 21:08
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 have not run

@mstv mstv merged commit 022311a into gitextensions:master Apr 1, 2025
4 checks passed
@mstv mstv deleted the fix/animated_gif branch April 1, 2025 17:44
@mstv mstv added this to the v5.3 milestone Apr 1, 2025
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

Successfully merging this pull request may close these issues.

[NBug] A generic error occurred in GDI+.
3 participants