Coder Social home page Coder Social logo

request: add ondestroy handler about libui HOT 6 CLOSED

andlabs avatar andlabs commented on June 9, 2024
request: add ondestroy handler

from libui.

Comments (6)

andlabs avatar andlabs commented on June 9, 2024

I could probably do this soon, sure. (Right now my Go bindings keep track of child controls and manually calls Destroy() on them as well. Perhaps with this commit I wouldn't need to do that...?)

from libui.

joaoventura avatar joaoventura commented on June 9, 2024

This may also be a problem for a python wrapper..

from libui.

gnarz avatar gnarz commented on June 9, 2024

I have started along a similar venue, but that was getting way too complicated. An ondestroy handler seemed like a much simpler approach to me. As all control calls go through one function, this shouldn't be too hard.

from libui.

DemiMarie avatar DemiMarie commented on June 9, 2024

It should be per-widget. A global handler is not sufficiently flexible.

from libui.

pcwalton avatar pcwalton commented on June 9, 2024

This is wanted for my Rust bindings as well.

What I'm doing now as a workaround is (a) maintaining a list of windows; (b) leaking all controls until uiUninit() is called, at which point I iterate over all the windows and destroy them; (c) having every method that calls into the FFI ensure that uiInit() has been called and uiUninit() has not been called. This essentially creates a weak reference semantics for controls, but it's one that leaks controls until the entire UI system has been shut down.

Another alternative to this approach would be to reference count controls. Effectively, this would make Control objects have strong reference semantics instead of weak reference semantics (as in this proposal). In GTK and Cocoa, all controls are already reference counted anyway, so this doesn't add much overhead.

from libui.

andlabs avatar andlabs commented on June 9, 2024

Merged with #325.

from libui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.