Skip to content

Commit f00b28d

Browse files
i509VCBvberger
authored andcommittedJun 8, 2022
server: allow using Resource::post_error without DisplayHandle
1 parent fc17276 commit f00b28d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎wayland-server/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ pub trait Resource: Sized {
7373
) -> Result<Message<ObjectId>, InvalidId>;
7474

7575
#[inline]
76-
fn post_error(&self, dh: &DisplayHandle, code: impl Into<u32>, error: impl Into<String>) {
77-
dh.post_error(self, code.into(), error.into())
76+
fn post_error(&self, code: impl Into<u32>, error: impl Into<String>) {
77+
if let Some(dh) = self.handle().upgrade().map(DisplayHandle::from) {
78+
dh.post_error(self, code.into(), error.into());
79+
}
7880
}
7981

8082
#[doc(hidden)]

‎wayland-tests/tests/protocol_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn client_receive_generic_error() {
4040
3,
4141
)
4242
.unwrap();
43-
compositor.post_error(&server.display.handle(), 42u32, "I don't like you!");
43+
compositor.post_error(42u32, "I don't like you!");
4444

4545
// the error has not yet reached the client
4646
assert!(client.conn.protocol_error().is_none());

0 commit comments

Comments
 (0)
Please sign in to comment.