-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
screen.Exit() called within a button lambda sometimes causes thread deadlock and app freeze #927
Comments
Hello! while (true) { |
Hello! Sorry for the confusion. |
Thanks! I see. FTXUI::ScreenInteractive are only "quittable" once. So, after you quit, you end up running the external loop infinitely. You could use: #include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/component/component.hpp"
#include "ftxui/component/screen_interactive.hpp"
int main() {
while (true) {
auto screen = ftxui::ScreenInteractive::TerminalOutput();
auto buttontest = ftxui::Button("test", [&] { });
auto button = ftxui::Button("Exit", [&] { screen.Exit(); });
auto container = ftxui::Container::Vertical({buttontest, button});
auto renderer = ftxui::Renderer(container, [&] {
return ftxui::vbox({ buttontest->Render(), button->Render() }) | ftxui::center;
});
screen.Loop(renderer);
}
} to fix your problem. I wonder what we can improve. Maybe adding an assertion to make it obvious to users? Implement "restartable" ScreenInteractive maybe? |
This code suffers from the same problem, which means that its not caused by exiting the same screen multiple times, the issue still persists. I just tried it out, after 10 exits this froze too. |
basically anytime exit() is called in a button this thread problem has a 2-3% chance of happening, which is very weird and annoying. This needs further investigation. |
Hello. Can you move this back to issues please? |
Title describes the problem pretty well. Code to replicate problem:
Pressing the Exit button repeatedly will freeze the program. It sometimes takes a lot of presses but eventually it happens. Its pretty annoying because i use this scenario in my project and the freeze happens often enough to be very annoying. How can i fix this?
The text was updated successfully, but these errors were encountered: