aboutsummaryrefslogtreecommitdiff
path: root/src/ui/host/RoutedEventDispatch.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-16 22:42:34 +0800
committercrupest <crupest@outlook.com>2022-02-16 22:42:34 +0800
commitf75ab0bd662c73d15057d746347d09bf94a992a6 (patch)
tree91efc33de481edf5304001d80b914b69cc0fb338 /src/ui/host/RoutedEventDispatch.h
parent2711b7032cafdc9bdbd6ae06db0325c91e6e7f63 (diff)
downloadcru-f75ab0bd662c73d15057d746347d09bf94a992a6.tar.gz
cru-f75ab0bd662c73d15057d746347d09bf94a992a6.tar.bz2
cru-f75ab0bd662c73d15057d746347d09bf94a992a6.zip
...
Diffstat (limited to 'src/ui/host/RoutedEventDispatch.h')
-rw-r--r--src/ui/host/RoutedEventDispatch.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ui/host/RoutedEventDispatch.h b/src/ui/host/RoutedEventDispatch.h
index ae1421ee..2ab51645 100644
--- a/src/ui/host/RoutedEventDispatch.h
+++ b/src/ui/host/RoutedEventDispatch.h
@@ -25,6 +25,8 @@ void DispatchEvent(
controls::Control* const original_sender,
events::RoutedEvent<EventArgs>* (controls::Control::*event_ptr)(),
controls::Control* const last_receiver, Args&&... args) {
+ if (original_sender == nullptr) return;
+
CRU_UNUSED(event_name)
if (original_sender == last_receiver) {
@@ -41,7 +43,9 @@ void DispatchEvent(
auto parent = original_sender;
while (parent != last_receiver) {
receive_list.push_back(parent);
- parent = parent->GetParent();
+ auto p = parent->GetParent();
+ assert(!(p == nullptr && last_receiver != nullptr));
+ parent = p;
}
if constexpr (debug_flags::routed_event) {