image-copy: Don't panic if ImageCaptureSourceKind udata is undefined
We want to merge this when updating Smithay to have https://github.com/Smithay/smithay/pull/1961, so that we don't panic the the output/toplevel already has no strong references when the source is created.
This commit is contained in:
parent
53e0db28ac
commit
472ffa5f30
2 changed files with 15 additions and 42 deletions
|
|
@ -37,9 +37,13 @@ pub enum ImageCaptureSourceKind {
|
|||
}
|
||||
|
||||
impl ImageCaptureSourceKind {
|
||||
pub fn from_resource(resource: &ExtImageCaptureSourceV1) -> Option<Self> {
|
||||
let source = ImageCaptureSource::from_resource(resource)?;
|
||||
source.user_data().get::<ImageCaptureSourceKind>().cloned()
|
||||
pub fn from_source(source: &ImageCaptureSource) -> Self {
|
||||
// If no user-data, assume source was created for a destroyed output, etc.
|
||||
source
|
||||
.user_data()
|
||||
.get::<ImageCaptureSourceKind>()
|
||||
.cloned()
|
||||
.unwrap_or(Self::Destroyed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue