Skip to content
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

Add type_name to panic error messages in WidgetPod #2380

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ You can find its changes [documented below](#083---2023-02-28).

### Added

- Type name is now included in panic error messages in WidgetPod ([#2380] by [@matthewgapp])
matthewgapp marked this conversation as resolved.
Show resolved Hide resolved

### Changed

### Deprecated
Expand Down
18 changes: 12 additions & 6 deletions druid/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {

if !self.is_initialized() {
debug_panic!(
"{:?}: paint method called before receiving WidgetAdded.",
"{:?} with widget id {:?}: paint method called before receiving WidgetAdded.",
self.inner.type_name(),
ctx.widget_id()
);
return;
Expand Down Expand Up @@ -549,7 +550,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
) -> Size {
if !self.is_initialized() {
debug_panic!(
"{:?}: layout method called before receiving WidgetAdded.",
"{:?} with widget id {:?}: layout method called before receiving WidgetAdded.",
self.inner.type_name(),
ctx.widget_id()
);
return Size::ZERO;
Expand Down Expand Up @@ -608,7 +610,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
pub fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut T, env: &Env) {
if !self.is_initialized() {
debug_panic!(
"{:?}: event method called before receiving WidgetAdded.",
"{:?} with widget id {:?}: event method called before receiving WidgetAdded.",
self.inner.type_name(),
ctx.widget_id()
);
return;
Expand All @@ -617,8 +620,9 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
// log if we seem not to be laid out when we should be
if self.state.is_expecting_set_origin_call && !event.should_propagate_to_hidden() {
warn!(
"{:?} received an event ({:?}) without having been laid out. \
"{:?} with widget id {:?} received an event ({:?}) without having been laid out. \
This likely indicates a missed call to set_origin.",
self.inner.type_name(),
ctx.widget_id(),
event,
);
Expand Down Expand Up @@ -1015,7 +1019,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
}
_ if !self.is_initialized() => {
debug_panic!(
"{:?}: received LifeCycle::{:?} before WidgetAdded.",
"{:?} with widget id {:?}: received LifeCycle::{:?} before WidgetAdded.",
self.inner.type_name(),
self.id(),
event
);
Expand Down Expand Up @@ -1149,7 +1154,8 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
(Some(_), None) => self.env = Some(env.clone()),
(None, _) => {
debug_panic!(
"{:?} is receiving an update without having first received WidgetAdded.",
"{:?} with widget id {:?} is receiving an update without having first received WidgetAdded.",
self.inner.type_name(),
self.id()
);
return;
Expand Down