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

Gir think that array is optional in futures #829

Open
EPashkin opened this issue Aug 17, 2019 · 4 comments
Open

Gir think that array is optional in futures #829

EPashkin opened this issue Aug 17, 2019 · 4 comments

Comments

@EPashkin
Copy link
Member

EPashkin commented Aug 17, 2019

Ex. parameter uris converted with map

    #[cfg(any(feature = "futures", feature = "dox"))]
    #[cfg(any(feature = "v2_60", feature = "dox"))]
    fn launch_uris_async_future<P: IsA<AppLaunchContext> + Clone + 'static>(
        &self,
        uris: &[&str],
        context: Option<&P>,
    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
        use fragile::Fragile;
        use GioFuture;

        let uris = uris.map(ToOwned::to_owned);
        let context = context.map(ToOwned::to_owned);
        GioFuture::new(self, move |obj, send| {
            let cancellable = Cancellable::new();
            let send = Fragile::new(send);
            obj.launch_uris_async(
                uris.as_ref().map(::std::borrow::Borrow::borrow),
                context.as_ref().map(::std::borrow::Borrow::borrow),
                Some(&cancellable),
                move |res| {
                    let _ = send.into_inner().send(res);
                },
            );

            cancellable
        })
    }

cc @sdroege, @GuillaumeGomez

Found in gtk-rs/gtk#866

@EPashkin
Copy link
Member Author

Write this function tough for me (lifetime problem)
so I add "no_future" flag to gir to possibility to disable future generation,
and this function can be added separately as manual.

@sdroege
Copy link
Member

sdroege commented Aug 18, 2019

The non-futures version of this function is equally broken. The uris have to stay alive until finish() function is called, which is not guaranteed in either case currently.

We need to convert to some owned array of owned strings before calling launch_uris_async() and ensure that this stays alive long enough.

@EPashkin
Copy link
Member Author

I tried that but can't solve problem with lifetimes,
as this function is blocker I propose to ignore it, until we can find manual or generated solution

@sdroege
Copy link
Member

sdroege commented Aug 18, 2019

Not sure what problem you ran into, this is basically like write_async :) But yes, for now ignore the async and futures variant until someone has to time to add a manual implementation.

Please create an issue in gio so we don't forget it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants