diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f1d43014e..af373a3ffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ You can find its changes [documented below](#070---2021-01-01). - Shell: IME API and macOS IME implementation ([#1619] by [@lord]) - Scroll::content_must_fill and a few other new Scroll methods ([#1635] by [@cmyr]) - New `TextBox` widget with IME integration ([#1636] by [@cmyr]) +- `Notification`s can be submitted while handling other `Notification`s ([#1640] by [@cmyr]) - Added ListIter implementations for OrdMap ([#1641] by [@Lejero]) ### Changed @@ -39,6 +40,8 @@ You can find its changes [documented below](#070---2021-01-01). ### Removed ### Fixed +- `Notification`s will not be delivered to the widget that sends them ([#1640] by [@cmyr]) + - Fixed docs of derived Lens ([#1523] by [@Maan2003]) - Use correct fill rule when rendering SVG paths ([#1606] by [@SecondFlight]) @@ -638,6 +641,7 @@ Last release without a changelog :( [#1634]: https://github.com/linebender/druid/pull/1634 [#1635]: https://github.com/linebender/druid/pull/1635 [#1636]: https://github.com/linebender/druid/pull/1636 +[#1640]: https://github.com/linebender/druid/pull/1640 [#1641]: https://github.com/linebender/druid/pull/1641 [#1647]: https://github.com/linebender/druid/pull/1647 diff --git a/druid/src/core.rs b/druid/src/core.rs index 2c542275ae..3fd80cdd8f 100644 --- a/druid/src/core.rs +++ b/druid/src/core.rs @@ -858,18 +858,16 @@ impl> WidgetPod { notifications: parent_notifications, .. } = ctx; - let mut sentinal = VecDeque::new(); let self_id = self.id(); let mut inner_ctx = EventCtx { state, - notifications: &mut sentinal, + notifications: parent_notifications, widget_state: &mut self.state, is_handled: false, is_root: false, }; - for _ in 0..notifications.len() { - let notification = notifications.pop_front().unwrap(); + for notification in notifications.drain(..) { // skip notifications that were submitted by our child if notification.source() != self_id { let event = Event::Notification(notification); @@ -878,21 +876,15 @@ impl> WidgetPod { inner_ctx.is_handled = false; } else if let Event::Notification(notification) = event { // we will try again with the next parent - parent_notifications.push_back(notification); + inner_ctx.notifications.push_back(notification); } else { + // could be unchecked but we avoid unsafe in druid :shrug: unreachable!() } } else { - parent_notifications.push_back(notification); + inner_ctx.notifications.push_back(notification); } } - - if !inner_ctx.notifications.is_empty() { - warn!( - "A Notification was submitted while handling another \ - notification; the submitted notification will be ignored." - ); - } } /// Propagate a [`LifeCycle`] event.