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

Initialize render target when window size is not specified on Windows #1575

Merged
merged 1 commit into from
Feb 17, 2021

Conversation

Perlmint
Copy link
Contributor

@Perlmint Perlmint commented Feb 9, 2021

Fix #1426.

As I commented on that issue, When the window size is not specified, WM_RESIZE is not emitted before first WM_PAINT. So, rendering is called without creating the render target.

I tested on Windows 10 Pro 20H2. With this patch, all examples are successfully showing the window without panic.

@Ciantic
Copy link
Collaborator

Ciantic commented Feb 15, 2021

This also fixes #1582. I'm okay with this patch for the time being (I don't know the side effects of creating DC during WM_CREATE either but it worked).

Reason is that way render_target is created is really unorthodox at the moment, I might make a bigger PR to refactor whole render_target creation. Usually DC or equivalent is created on demand during render (e.g. WM_PAINT).

Right now the render function just unwraps the render_target and crashes if it's not there. It should instead create the render target in render function if it doesn't exist.

@cmyr cmyr added the S-needs-review waits for review label Feb 15, 2021
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Okay, I'm happy to merge this as a hotfix with the understanding that we would like a more robust solution longer-term.

@cmyr cmyr merged commit f5fd4b0 into linebender:master Feb 17, 2021
@Perlmint Perlmint deleted the fix/windows_init_without_size branch March 5, 2021 13:19
@maan2003 maan2003 removed the S-needs-review waits for review label May 3, 2021
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.

thread 'main' panicked at 'called Option::unwrap() on a None value'
4 participants