wayland.data_device: Early return on protocol error
This commit is contained in:
parent
6856ae891f
commit
c136cd5f34
|
@ -273,24 +273,28 @@ fn implement_dnd_data_offer(
|
|||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer that is no longer active.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if !data.accepted {
|
||||
offer.as_ref().post_error(
|
||||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer that has not been accepted.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if !data.dropped {
|
||||
offer.as_ref().post_error(
|
||||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer that has not been dropped.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if data.chosen_action.is_empty() {
|
||||
offer.as_ref().post_error(
|
||||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer with no valid action.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
source.dnd_finished();
|
||||
data.active = false;
|
||||
|
@ -309,6 +313,7 @@ fn implement_dnd_data_offer(
|
|||
wl_data_offer::Error::InvalidAction as u32,
|
||||
"Invalid preferred action.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let source_actions = with_source_metadata(&source, |meta| meta.dnd_action)
|
||||
.unwrap_or_else(|_| DndAction::empty());
|
||||
|
|
|
@ -268,24 +268,28 @@ where
|
|||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer that is no longer active.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if !data.accepted {
|
||||
offer.as_ref().post_error(
|
||||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer that has not been accepted.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if !data.dropped {
|
||||
offer.as_ref().post_error(
|
||||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer that has not been dropped.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if data.chosen_action.is_empty() {
|
||||
offer.as_ref().post_error(
|
||||
wl_data_offer::Error::InvalidFinish as u32,
|
||||
"Cannot finish a data offer with no valid action.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
(&mut *callback.borrow_mut())(ServerDndEvent::Finished);
|
||||
data.active = false;
|
||||
|
@ -304,6 +308,7 @@ where
|
|||
wl_data_offer::Error::InvalidAction as u32,
|
||||
"Invalid preferred action.".into(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let possible_actions = metadata.dnd_action & dnd_actions;
|
||||
data.chosen_action = (&mut *action_choice.borrow_mut())(possible_actions, preferred_action);
|
||||
|
|
Loading…
Reference in New Issue