Skip to content
This repository has been archived by the owner on Jun 8, 2021. 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 commented Jul 20, 2019 via email

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

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 commented Jul 21, 2019

Looks good otherwise

uris: &[&str],
launch_context: Option<&P>,
spawn_flags: glib::SpawnFlags,
user_setup: Option<Box_<dyn FnOnce() + 'static>>,
Copy link
Member

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

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

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

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

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

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

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

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

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

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 Compare October 23, 2019 12:52
@sdroege
Copy link
Member

sdroege commented Nov 2, 2019

This is obsolete now?

@GuillaumeGomez
Copy link
Member Author

I guess?

@GuillaumeGomez GuillaumeGomez deleted the regen-with-nullable-callbacks branch November 2, 2019 16:55
@GuillaumeGomez
Copy link
Member Author

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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants