Bug 136923

Summary: [GTK] Dot not allow to create delete-on-destroy GMainLoopSources
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: Web Template FrameworkAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: gustavo, zan
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch gustavo: review+

Description Carlos Garcia Campos 2014-09-18 08:09:37 PDT
We have several asserts to ensure that delete-on-destroy sources are not misused, like not scheduling socket sources on a delete on destroy GMainLoopSource or not allowing to cancel them before they have been dispatched. It would be better if we can ensure all those things at compile time, so instead of having  static method to create a delete-on-destroy source with all the API available, we could add static methods to schedule sources creating a delete-on-destroy GMainLoopSource that is not returned to the user.
Comment 1 Carlos Garcia Campos 2014-09-18 08:17:06 PDT
Created attachment 238309 [details]
Patch
Comment 2 Carlos Garcia Campos 2014-09-18 08:51:32 PDT
Created attachment 238310 [details]
Patch
Comment 3 Gustavo Noronha (kov) 2014-09-18 13:08:47 PDT
Comment on attachment 238310 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238310&action=review

> Source/WTF/wtf/gobject/GMainLoopSource.cpp:36
> -GMainLoopSource& GMainLoopSource::createAndDeleteOnDestroy()
> +GMainLoopSource& GMainLoopSource::create()

I think this name should be kept, otherwise it may lead people to believe that this is the default or only way of creating, like on other objects, it gets confusing.

> Source/WTF/wtf/gobject/GMainLoopSource.cpp:-85
> -    // Delete-on-destroy GMainLoopSource objects can only be cancelled when there's callback either scheduled
> -    // or in the middle of dispatch. At that point cancellation will have no effect.
> -    ASSERT(m_deleteOnDestroy != DeleteOnDestroy || (m_status == Ready && !m_context.source));

Heh, this was a bit weird.
Comment 4 Carlos Garcia Campos 2014-09-18 23:34:04 PDT
(In reply to comment #3)
> (From update of attachment 238310 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=238310&action=review
> 
> > Source/WTF/wtf/gobject/GMainLoopSource.cpp:36
> > -GMainLoopSource& GMainLoopSource::createAndDeleteOnDestroy()
> > +GMainLoopSource& GMainLoopSource::create()
> 
> I think this name should be kept, otherwise it may lead people to believe that this is the default or only way of creating, like on other objects, it gets confusing.

But I made it private for that reason, so it can only be created inside the object.

> > Source/WTF/wtf/gobject/GMainLoopSource.cpp:-85
> > -    // Delete-on-destroy GMainLoopSource objects can only be cancelled when there's callback either scheduled
> > -    // or in the middle of dispatch. At that point cancellation will have no effect.
> > -    ASSERT(m_deleteOnDestroy != DeleteOnDestroy || (m_status == Ready && !m_context.source));
> 
> Heh, this was a bit weird.

Yes.
Comment 5 Carlos Garcia Campos 2014-09-18 23:51:40 PDT
Committed r173749: <http://trac.webkit.org/changeset/173749>