switch to using microtasks for switching, fixing segfaults
This commit is contained in:
parent
c601beb28e
commit
bbec75f451
1 changed files with 9 additions and 6 deletions
|
@ -4,12 +4,15 @@
|
|||
DirectoryView::~DirectoryView() {}
|
||||
|
||||
void DirectoryView::update() {
|
||||
window()->start_batch();
|
||||
// microtasks defer execution of the callback until all external events are processed.
|
||||
// if they're not used here and update() is called in a click or hover handler,
|
||||
// chaos will ensue, as the widget tree will be updated during event propagation
|
||||
window()->queue_microtask([this]() {
|
||||
target()->clear_children();
|
||||
for (const auto &entry : std::filesystem::directory_iterator(m_current_path)) {
|
||||
auto button = m_target->add<FileButton>(entry.path().filename(), this);
|
||||
}
|
||||
window()->end_batch();
|
||||
});
|
||||
}
|
||||
|
||||
void DirectoryView::navigate(std::string path) {
|
||||
|
|
Loading…
Reference in a new issue