aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
276 stars 60 forks source link

Force zero init of X11 class. #35

Closed slembcke closed 2 years ago

slembcke commented 2 years ago

Running Aseprite batch mode (using -b) as part of a headless asset build process was causing it to segfault in XInput::~XInput() because m_xi was uninitialized. Forcing zero initialization fixes it.

I agree that my contributions are licensed under the Laf license, and agree to future changes to the licensing.

iamOgunyinka commented 2 years ago

Isn't this what's known as most-vexing parse?

dacap commented 2 years ago

Hi @slembcke, I think your change, as @iamOgunyinka said, might be converting the calling of os::X11 constructor to create x11 instance, to a function definition (so the instance is not created, and maybe the ctor/dtor not even called).

I've pushed a possible fix here. Initializing the m_xi pointer (the pointer inside XInput class) correctly. Could you check if this fix your problem?

slembcke commented 2 years ago

That commit seems to fix the issue as well. Thanks!

(edit: irrelevant C++ joke removed)