Git Product home page Git Product logo

Comments (5)

binary1248 avatar binary1248 commented on May 31, 2024

Don't remove the widget when your are inside the signal handler. This will lead to undefined behaviour. Remember what you have to remove and remove it after your call to HandleEvent() returns.

from sfgui.

Zetal911 avatar Zetal911 commented on May 31, 2024

Is there an example available that shows how to do this? (Desktop.cpp seems to 'remove' inside the signal handler, unless I'm misunderstanding the terminology?)

from sfgui.

binary1248 avatar binary1248 commented on May 31, 2024

In the case of Desktop.cpp, we first create another shared_ptr to the widget we want to remove, remove it and return from the handler. We also make sure not to try to manipulate the object too much. Once we remove it we must assume it is no longer safe to access. The example was written this way to stay short, and given its simplicity we could also manage the dangers that are associated with this method. We wouldn't recommend doing this in anything more complex than this scenario however.

from sfgui.

Zetal911 avatar Zetal911 commented on May 31, 2024

Sorry to bother you again, but what do you mean by "Remember what you have to remove and remove it after your call to HandleEvent() returns."?

Does this mean storing the widget to be removed inside of a class or global variable and then deleting it inside of the while (mainWindow.pollEvent(event)) code block?

from sfgui.

binary1248 avatar binary1248 commented on May 31, 2024

Does this mean storing the widget to be removed inside of a class or global variable and then deleting it inside of the while (mainWindow.pollEvent(event)) code block?

Yes.

from sfgui.

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.