lv2 / pugl

A minimal portable API for embeddable GUIs
https://gitlab.com/lv2/pugl/
ISC License
174 stars 34 forks source link

MacOS: Possibility of infinite loop when resizing while configuring #109

Open mfisher31 opened 11 months ago

mfisher31 commented 11 months ago

Calling move/resize view functions while inside a configure event from calling code causes an infinite loop ...

[window dispatchCurrentConfiguration];
dispatchCurrentChildViewConfiguration(view);

... these get called from puglSetFrame and related functions which in turn sends another configure event in the same stroke... and down it goes!

I'm avoiding this with simple bool flag here, and handling later in puglUpdate: https://gitlab.com/lvtk/pugl/-/commit/3a3ede7f3f2e9571fc59230c36be60cebec02e19

Kind of a scratch pad solution, but the infinite loop is real.

drobilla commented 11 months ago

I can see what led you here, but you probably never want to actually do that; it's going to be a nightmare in all kinds of ways, and different kinds of ways on different platforms for extra fun.

It should probably fail gracefully when called in this and other inappropriate contexts, as should a bunch of other things. I've been working on improving the internal state tracking for this among other things, but there's still a lot of checks needed to make things resilient.

mfisher31 commented 7 months ago

Good call. Things like this can easily become a nightmare... especially when just "going for it" and it gets baked in the code base forever.