Skip to content

Fix CGDisplayMode bindings#318

Closed
ghost wants to merge 1 commit intomasterfrom
unknown repository
Closed

Fix CGDisplayMode bindings#318
ghost wants to merge 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jun 14, 2019

There was some bizarre behaviour going on with CGDisplayMode::all_display_modes(), which I believe was resulting in objects being freed that weren't supposed to. In my project, all calls to CGConfigureDisplayWithDisplayMode() would crash after this function call, and any subsequent calls to CGDisplayMode::all_display_modes() would crash as well.

Familiarising myself with this codebase, I think the right solution here is to wrap the array elements with TCFType::wrap_under_get_rule() as indicated by the comment in the CFArray::iter() function. In order to do this, instead of the foreign_type!() macro we will have to use impl_TCFType!() for the CGDisplayMode type.


This change is Reviewable

@ghost ghost mentioned this pull request Jun 25, 2019
10 tasks
@ghost
Copy link
Copy Markdown
Author

ghost commented Jun 26, 2019

I'm not entirely convinced that this is correct either. I'm having a hard time wrapping my head around the implementation details of this crate, so I've worked around the issue by rolling my own bindings and using carefully placed CGDisplayModeRetain and CGDisplayModeRelease calls.

@ghost ghost closed this Jun 26, 2019
@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 26, 2019

Sorry for forgetting about this. Could you file an issue with sample code that reproduces the problem?

@ghost
Copy link
Copy Markdown
Author

ghost commented Jun 26, 2019

I've filed issue #319 to track this.

This pull request was closed.
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.

2 participants