Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

SourceId should implement remove #386

Closed
GuillaumeGomez opened this issue Nov 3, 2018 · 11 comments
Closed

SourceId should implement remove #386

GuillaumeGomez opened this issue Nov 3, 2018 · 11 comments

Comments

@GuillaumeGomez
Copy link
Member

For now, we're forced to call source_remove and pass the SourceId as parameter. Not very nice...

@sdroege
Copy link
Member

sdroege commented Nov 3, 2018

That would be tricky as you'd need to carry additional things (the main context) around with the source id, potentially causing memory leaks

@GuillaumeGomez
Copy link
Member Author

We'll just call the function inside it directly. I had something like this in mind:

impl SourceId {
    pub fn remove(self) {
        glib::source_remove(self);
    }
}

@sdroege
Copy link
Member

sdroege commented Nov 3, 2018

That only works for sources on the default main context and will otherwise cause assertions or worse

@GuillaumeGomez
Copy link
Member Author

This is already the case with the function itself so I think I'm missing something here...

@sdroege
Copy link
Member

sdroege commented Nov 3, 2018

You need the function on the main context, not the global/free function

@GuillaumeGomez
Copy link
Member Author

Yes but again, we're just doing exactly the same as before except that we wrapped it into a method.

@sdroege
Copy link
Member

sdroege commented Nov 3, 2018

How would you get the main context into the method?

@GuillaumeGomez
Copy link
Member Author

I don't understand why you're talking about context. In the function, there is no such thing: http://gtk-rs.org/docs/src/glib/source.rs.html#256-260

@sdroege
Copy link
Member

sdroege commented Nov 3, 2018

That's exactly my point. You can only call this function for source ids that came from the default main context :) To quote the documentation

Removes the source with the given ID from the default main context. You must use g_source_destroy() for sources added to a non-default main context.

@GuillaumeGomez
Copy link
Member Author

Ok I got it. Well then, it'd be even safer to actually have this additional information. Like that, no chance to call the wrong function.

@sdroege
Copy link
Member

sdroege commented Jun 19, 2019

Let's close this then until someone comes up with a real need for this?

@sdroege sdroege closed this as completed Jun 19, 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

No branches or pull requests

2 participants