mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-18 00:48:09 +08:00
Fix component ownership.
When switching from raw pointers toward shared_ptr, the destructor wasn't updated correctly. This patch: - Fixes the issue. - Add two regression tests. - Use address sanitizer for the tests. This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/115
This commit is contained in:

committed by
Arthur Sonzogni

parent
478d7e8bca
commit
91c5954fe2
@@ -19,7 +19,8 @@ class CaptureMouseImpl : public CapturedMouseInterface {
|
||||
} // namespace
|
||||
|
||||
ComponentBase::~ComponentBase() {
|
||||
Detach();
|
||||
while (children_.size() != 0)
|
||||
children_.back()->Detach();
|
||||
}
|
||||
|
||||
/// @brief Return the parent ComponentBase, or nul if any.
|
||||
@@ -142,6 +143,7 @@ void ComponentBase::Detach() {
|
||||
return this == that.get();
|
||||
});
|
||||
parent_->children_.erase(it);
|
||||
parent_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace ftxui
|
||||
|
Reference in New Issue
Block a user