Skip to content

client/rs: Using destroyed object in argument still sends request to server, unlike on sys backend #801

@ids1024

Description

@ids1024

This minimal test case gets an Unknown id protocol error with the rs backend, but not with wayland-backend/client_system.

Presumably these should be consistent, and the rs backend should also drop the get_subsurface call here.

use wayland_client::{
    delegate_noop,
    globals::{registry_queue_init, GlobalListContents},
    protocol::{wl_compositor, wl_registry, wl_subcompositor, wl_subsurface, wl_surface},
    Connection, Dispatch, QueueHandle,
};

struct State;

fn main() {
    let conn = Connection::connect_to_env().unwrap();
    let (globals, mut event_queue) = registry_queue_init(&conn).unwrap();
    let qh = event_queue.handle();

    let compositor = globals.bind::<wl_compositor::WlCompositor, _, _>(&qh, 1..=1, ()).unwrap();
    let subcompositor =
        globals.bind::<wl_subcompositor::WlSubcompositor, _, _>(&qh, 1..=1, ()).unwrap();

    let surface = compositor.create_surface(&qh, ());
    let surface2 = compositor.create_surface(&qh, ());
    surface.destroy();
    let _subsurface = subcompositor.get_subsurface(&surface, &surface2, &qh, ());

    loop {
        event_queue.blocking_dispatch(&mut State).unwrap();
    }
}

impl Dispatch<wl_registry::WlRegistry, GlobalListContents> for State {
    fn event(
        _: &mut Self,
        _: &wl_registry::WlRegistry,
        _: wl_registry::Event,
        _: &GlobalListContents,
        _: &Connection,
        _: &QueueHandle<State>,
    ) {
    }
}
delegate_noop!(State: wl_compositor::WlCompositor);
delegate_noop!(State: ignore wl_surface::WlSurface);
delegate_noop!(State: wl_subcompositor::WlSubcompositor);
delegate_noop!(State: wl_subsurface::WlSubsurface);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions