<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X11] Add XUniquePtr and XUniqueResource to automatically free X resources"
   href="https://bugs.webkit.org/show_bug.cgi?id=144521">bug 144521</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #252709 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X11] Add XUniquePtr and XUniqueResource to automatically free X resources"
   href="https://bugs.webkit.org/show_bug.cgi?id=144521#c14">Comment # 14</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X11] Add XUniquePtr and XUniqueResource to automatically free X resources"
   href="https://bugs.webkit.org/show_bug.cgi?id=144521">bug 144521</a>
              from <span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=252709&amp;action=diff" name="attach_252709" title="Addressed review comments">attachment 252709</a> <a href="attachment.cgi?id=252709&amp;action=edit" title="Addressed review comments">[details]</a></span>
Addressed review comments

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=252709&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=252709&amp;action=review</a>

<span class="quote">&gt; Source/WebCore/platform/graphics/glx/GLContextGLX.h:62
&gt;      XID m_window;</span >

If we initialized this here then all the constructors would be simpler.

<span class="quote">&gt; Source/WebCore/platform/graphics/glx/GLContextGLX.h:66
&gt;      cairo_device_t* m_cairoDevice;</span >

If we initialized this here then all the constructors would be simpler.

<span class="quote">&gt; Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp:199
&gt; +    m_image.reset();</span >

We often write this in the WebKit project as:

    m_image = nullptr;

<span class="quote">&gt; Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp:223
&gt; +    m_image.reset();</span >

We often write this in the WebKit project as:

    m_image = nullptr;

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniquePtr.h:43
&gt; +template&lt;typename T&gt;
&gt; +struct XPtrDeleter {
&gt; +    void operator()(T* ptr) const { XFree(ptr); }
&gt; +};</span >

The version of this I wrote had a null check, and the documentation for XFree makes it clear it can’t be called with a null. Why is it OK to omit a null check here?

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniquePtr.h:74
&gt; +DEFINE_XPTR_DELETER(XImage, XDestroyImage)
&gt; +DEFINE_XPTR_DELETER_WITH_DISPLAY(_XGC, XFreeGC)
&gt; +
&gt; +#if USE(GLX)
&gt; +DEFINE_XPTR_DELETER_WITH_DISPLAY(__GLXcontextRec, glXDestroyContext)
&gt; +#endif</span >

I don’t think it’s a good idea to use macros for these. One is only used once and the other is only used twice. Writing that second template specialization twice seems like it would be fine.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.cpp:44
&gt; +template&lt;&gt; void XUniqueResource&lt;XResource::Colormap&gt;::deleteXResource(long unsigned resource)</span >

I don’t understand why this works in a cpp file. As I understand it, template specializations need to be in headers.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.cpp:47
&gt; +        XFreeColormap(downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native(), resource);</span >

The repeated code downcast&lt;PlatformDisplayX11&gt;(PlatformDisplay::sharedDisplay()).native() should be a helper function, not written out each time.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.cpp:51
&gt; +template &lt;&gt; void XUniqueResource&lt;XResource::Damage&gt;::deleteXResource(long unsigned resource)</span >

Would be nice to be consistent about whether there is a space after template.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.h:54
&gt; +        : m_resource(0)</span >

Would be better to initialize to zero when m_resource is defined below.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.h:79
&gt; +    long unsigned get() const { return m_resource; }</span >

WebKit project uses &quot;unsigned long&quot;, not &quot;long unsigned&quot;.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.h:95
&gt; +    // This conversion operator allows implicit conversion to bool but not to other integer types.
&gt; +    typedef void* (XUniqueResource::*UnspecifiedBoolType);
&gt; +    operator UnspecifiedBoolType*() const
&gt; +    {
&gt; +        return m_resource ? reinterpret_cast&lt;UnspecifiedBoolType*&gt;(1) : 0;
&gt; +    }</span >

explicit operator bool is the modern way to do this, unless you need to be compatible with some broken compiler.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.h:98
&gt; +    XUniqueResource(const XUniqueResource&amp;) = delete;
&gt; +    XUniqueResource&amp; operator=(const XUniqueResource&amp;) = delete;</span >

These are unneeded. Defining move constructor and move assignment operator does this automatically.

<span class="quote">&gt; Source/WebCore/platform/graphics/x11/XUniqueResource.h:114
&gt; +using XUniqueColormap = XUniqueResource&lt;XResource::Colormap&gt;;
&gt; +#if PLATFORM(GTK)
&gt; +using XUniqueDamage = XUniqueResource&lt;XResource::Damage&gt;;
&gt; +#endif
&gt; +using XUniquePixmap = XUniqueResource&lt;XResource::Pixmap&gt;;
&gt; +using XUniqueWindow = XUniqueResource&lt;XResource::Window&gt;;
&gt; +#if USE(GLX)
&gt; +using XUniqueGLXPbuffer = XUniqueResource&lt;XResource::GLXPbuffer&gt;;
&gt; +using XUniqueGLXPixmap = XUniqueResource&lt;XResource::GLXPixmap&gt;;
&gt; +#endif</span >

Seems pretty weak that these aren’t checked at all. You could easily use the wrong one.

<span class="quote">&gt; Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:205
&gt; +    // Explicit reset these because we need to ensure it happens in this order.</span >

Typo: Explicitly is missing the &quot;ly&quot;.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>