Skip to content
This repository has been archived by the owner. It is now read-only.

Regen with nullable callbacks #230

Conversation

@GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jul 20, 2019

Requires gtk-rs/gir#815.

@sdroege
Copy link
Member

@sdroege sdroege commented Jul 20, 2019

pid_callback: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>,
stdin_fd: i32,
stdout_fd: i32,
stderr_fd: i32,
Copy link
Member

@sdroege sdroege Jul 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be generic over FromRawFd for the fds on UNIX and FromRawHandle on Windows. Like we do elsewhere.

Passing arbitrary numbers around as fds is unsafe.

@sdroege
Copy link
Member

@sdroege sdroege commented Jul 21, 2019

Looks good otherwise

@GuillaumeGomez GuillaumeGomez force-pushed the regen-with-nullable-callbacks branch from 1e10059 to 2b16006 Oct 19, 2019
uris: &[&str],
launch_context: Option<&P>,
spawn_flags: glib::SpawnFlags,
user_setup: Option<Box_<dyn FnOnce() + 'static>>,
Copy link
Member

@sdroege sdroege Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is correct or safe. The function is called once per process, so if you have multiple URIs... :) OTOH this is called right after fork() from what I understand. Unclear if FnOnce is correct in this case.

Copy link
Member

@sdroege sdroege Oct 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think?

Copy link
Member

@sdroege sdroege Oct 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unclear if Rust is supposed to be fork-safe, or if the closure needs to be marked unsafe anyway

pid_callback: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>,
stdin_fd: FD,
stdout_fd: FD,
stderr_fd: FD,
Copy link
Member

@sdroege sdroege Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should become a generic function with FD: IntoRawFd, or be marked as unsafe

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why IntoRawFd and not AsRawFd?

Copy link
Member

@sdroege sdroege Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You give ownership of the fds to the function or not?

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't, that's why I pcked As* instead of Into*.

Copy link
Member

@sdroege sdroege Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter what you would do :P What does the C function do?

Copy link
Member Author

@GuillaumeGomez GuillaumeGomez Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that the FDs need to be closed outside of the function: https://github.com/GNOME/gnome-shell/blob/master/src/shell-app.c#L1322

Therefore, we don't give ownership.

Copy link
Member

@sdroege sdroege Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you're right :)

@GuillaumeGomez GuillaumeGomez force-pushed the regen-with-nullable-callbacks branch 3 times, most recently from a714d79 to 6ec1700 Oct 23, 2019
@GuillaumeGomez GuillaumeGomez force-pushed the regen-with-nullable-callbacks branch from 6ec1700 to ef1e34f Oct 23, 2019
@sdroege
Copy link
Member

@sdroege sdroege commented Nov 2, 2019

This is obsolete now?

@GuillaumeGomez
Copy link
Member Author

@GuillaumeGomez GuillaumeGomez commented Nov 2, 2019

I guess?

@GuillaumeGomez GuillaumeGomez deleted the regen-with-nullable-callbacks branch Nov 2, 2019
@GuillaumeGomez
Copy link
Member Author

@GuillaumeGomez GuillaumeGomez commented Nov 2, 2019

Wait actually it wasn't: it added new objects. Well, let's first merge your regen PR, it'll make less noise.

@GuillaumeGomez GuillaumeGomez mentioned this pull request Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants