raw-gl-context icon indicating copy to clipboard operation
raw-gl-context copied to clipboard

Add more error checking on X11

Open prokopyl opened this issue 3 years ago • 4 comments

This PR adds some infrastructure to handle errors that can be raised when making X11 API calls:

  • Adds a private, platform-specific field to GlError::CreationFailed for implementations to add more information on the source of the failure for debugging. This is just an empty tuple for on non-X11 for now. This is a breaking change, as this breaks enum exhaustiveness.
  • Adds an XLibError helper struct, with a Debug implementation showing the text version of the error using XGetErrorText, to help debugging when using unwrap().
  • Adds an XErrorHandler helper struct, which helps setup a temporary error handler for the duration of a given closure (after which the previous error handler is restored, which is needed for embedding). It also ensures the error handler is properly restored after an early return or a panic.

prokopyl avatar Feb 04 '22 20:02 prokopyl

I realize this may be a bit late now (as it probably has been superseded by https://github.com/RustAudio/baseview/pull/115), but I did the small change anyway. :slightly_smiling_face:

Feel free to close this PR if this isn't relevant anymore.

prokopyl avatar Feb 25 '23 20:02 prokopyl

It's appreciated! I'll try to re-review and merge this when I get the chance.

glowcoil avatar Feb 25 '23 20:02 glowcoil

It would be great if you could also submit these changes for the OpenGL context creation in baseview. The code there was taken from the old version of this PR. Until baseview has some kind of API to hook into some low level window creation options the a separate raw-gl-context crate sadly cannot work correctly on Linux, so getting these improvements into baseview would help a lot in the meantime.

robbert-vdh avatar Feb 25 '23 20:02 robbert-vdh

The OpenGL context creation code in Baseview was already changed to use a thread local (see https://github.com/RustAudio/baseview/pull/115#discussion_r820871427), so I don't think there's anything in this PR that's missing from Baseview.

glowcoil avatar Feb 25 '23 21:02 glowcoil