<table><tr><td style="">dfaure requested changes to this revision.<br />dfaure added a comment.<br />This revision now requires changes to proceed.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D24962">View Revision</a></tr></table><br /><div><div><p>I like the approach.<br />
Just a few minor things.</p>

<p>(and remember to remove the WIP from the commit log and the phab request)</p>

<p>The passing of iterators to another thread *looks* scary, but of course it's safe here since we only run one subjob at a time, so the list can't change while the worker does its work.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140961">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:68</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"><span class="bright"></span><span style="color: #74777d"><span class="bright">    "DELETEJOB_STATE_STATING",</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"><span class="bright"></span><span style="color: #74777d"><span class="bright">    "DELETEJOB_STATE_DELETING_FILES",</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"><span class="bright"></span><span style="color: #74777d"><span class="bright">    "DELETEJOB_STATE_DELETING_DIRS"</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="bright"></span><span style="color: #aa4000"><span class="bright">public</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">:</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">can be removed</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140906">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:192</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_ioworker</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">new</span> <span class="n">DeleteJobIOWorkerPrivate</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_ioworker</span><span style="color: #aa2211">-></span><span class="n">moveToThread</span><span class="p">(</span><span style="color: #aa2211">&</span><span class="n">m_thread</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I would remove the "Private" from the name, it makes one think that there is a corresponding public class somewhere.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140957">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:194</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_ioworker</span><span style="color: #aa2211">-></span><span class="n">moveToThread</span><span class="p">(</span><span style="color: #aa2211">&</span><span class="n">m_thread</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_thread</span><span class="p">.</span><span class="n">connect</span><span class="p">(</span><span style="color: #aa2211">&</span><span class="n">m_thread</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">QThread</span><span style="color: #aa2211">::</span><span class="n">finished</span><span class="p">,</span> <span class="n">m_ioworker</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">QObject</span><span style="color: #aa2211">::</span><span class="n">deleteLater</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_ioworker</span><span style="color: #aa2211">-></span><span class="n">connect</span><span class="p">(</span><span class="n">m_ioworker</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">DeleteJobIOWorkerPrivate</span><span style="color: #aa2211">::</span><span class="n">rmddirResult</span><span class="p">,</span> <span class="p">[</span><span style="color: #aa2211">=</span><span class="p">](</span><span style="color: #aa4000">bool</span> <span class="n">result</span><span class="p">,</span> <span style="color: #aa4000">const</span> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QUrl</span><span style="color: #aa2211">>::</span><span class="n">iterator</span> <span class="n">it</span><span class="p">){</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">You're using the 4-args connect, which is static, so <tt style="background: #ebebeb; font-size: 13px;">m_thread.connect</tt> is confusing/wrong. This should be <tt style="background: #ebebeb; font-size: 13px;">QObject::connect</tt> instead.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140958">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:195</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_thread</span><span class="p">.</span><span class="n">connect</span><span class="p">(</span><span style="color: #aa2211">&</span><span class="n">m_thread</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">QThread</span><span style="color: #aa2211">::</span><span class="n">finished</span><span class="p">,</span> <span class="n">m_ioworker</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">QObject</span><span style="color: #aa2211">::</span><span class="n">deleteLater</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">m_ioworker</span><span style="color: #aa2211">-></span><span class="n">connect</span><span class="p">(</span><span class="n">m_ioworker</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">DeleteJobIOWorkerPrivate</span><span style="color: #aa2211">::</span><span class="n">rmddirResult</span><span class="p">,</span> <span class="p">[</span><span style="color: #aa2211">=</span><span class="p">](</span><span style="color: #aa4000">bool</span> <span class="n">result</span><span class="p">,</span> <span style="color: #aa4000">const</span> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QUrl</span><span style="color: #aa2211">>::</span><span class="n">iterator</span> <span class="n">it</span><span class="p">){</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #aa4000">this</span><span style="color: #aa2211">-></span><span class="n">rmdirResult</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">it</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Prefer QObject::connect(4 args), the receiver is missing and could be q_func() for extra safety (so that the connect is broken if the DeleteJob is deleted, even if m_ioworker is leaked for some reason).</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140956">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:359</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="p">}</span> <span style="color: #aa4000">else</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">deleteNextFile</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">(With the change I suggest below, this would just move to after <tt style="background: #ebebeb; font-size: 13px;">m_processedFiles++;</tt> above. This would simplify the control flow in this method)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140954">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:363</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="n">SimpleJob</span><span style="color: #aa2211">*</span> <span class="n">DeleteJobPrivate</span><span style="color: #aa2211">::</span><span class="n">deleteFileUsingJob</span> <span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QUrl</span><span style="color: #aa2211">>::</span><span class="n">iterator</span> <span class="n">it</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">No space after the method name.</p>

<p style="padding: 0; margin: 8px;">This method could take a QUrl instead of an iterator, all it does is <tt style="background: #ebebeb; font-size: 13px;">*it</tt> to get to the QUrl.</p>

<p style="padding: 0; margin: 8px;">Even better, it could keep using an iterator, but also take care of of the two <tt style="background: #ebebeb; font-size: 13px;">erase(it)</tt> calls and <tt style="background: #ebebeb; font-size: 13px;">addSubjob</tt>. This is currently duplicated between the two callers. The only difference is <tt style="background: #ebebeb; font-size: 13px;">bool isLink</tt>, you could pass that as parameter.</p>

<p style="padding: 0; margin: 8px;">This would even be more consistent with <tt style="background: #ebebeb; font-size: 13px;">DeleteJobPrivate::deleteDirUsingJob</tt> which takes care of <tt style="background: #ebebeb; font-size: 13px;">erase(it)</tt> and <tt style="background: #ebebeb; font-size: 13px;">addSubjob</tt>.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140959">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:388</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">        <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QUrl</span><span style="color: #aa2211">>::</span><span class="n">iterator</span> <span class="n">it</span> <span style="color: #aa2211">=</span> <span class="n">files</span><span class="p">.</span><span class="n">begin</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">        <span class="bright">    </span><span style="color: #aa4000">bool</span> <span class="n">isLink</span> <span style="color: #aa2211">=</span> <span class="bright"></span><span style="color: #304a96"><span class="bright">false</span></span><span class="bright"></span><span class="p"><span class="bright">;</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">        <span class="bright">    </span><span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">i<span class="bright">t</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">==</span></span><span class="bright"> </span><span class="n"><span class="bright">files</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">end</span></span><span class="bright"></span><span class="p"><span class="bright">())</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span><span class="bright"> </span><span style="color: #74777d"><span class="bright">// No more files</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #aa4000">bool</span> <span class="n">isLink</span> <span style="color: #aa2211">=</span> <span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">it</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">==</span></span><span class="bright"> </span><span class="n"><span class="bright">files</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">end</span></span><span class="bright"></span><span class="p"><span class="bright">());</span></span><span class="bright"> </span><span style="color: #74777d"><span class="bright">// No more files</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">i<span class="bright">sLink</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">You can make it <tt style="background: #ebebeb; font-size: 13px;">const</tt> then.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140909">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:397</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span class="bright">    </span><span style="color: #74777d"><span class="bright">//kdDebug(7007) << "DeleteJob deleted" << (*it).toLocalFile();</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span class="bright">    </span><span class="n"><span class="bright">job</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">nullptr</span></span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">            <span class="bright">    </span><span class="n"><span class="bright">m_processedFiles</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">++</span></span><span class="bright"></span><span class="p"><span class="bright">;</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="bright"></span><span style="color: #74777d"><span class="bright">// separate thread will do the work</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="bright"></span><span style="color: #74777d"><span class="bright">//m_ioworker->rmfile((*it).toLocalFile())</span>;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="bright"></span><span class="n"><span class="bright">QMetaObject</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="bright"></span><span class="n"><span class="bright">invokeMethod</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">m_ioworker</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">"rmfile"</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n"><span class="bright">Qt</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="bright"></span><span class="n"><span class="bright">QueuedConnection</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I suggest to remove the erroneous comment</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D24962#inline-140960">View Inline</a><span style="color: #4b4d51; font-weight: bold;">deletejob.cpp:461</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">                                      <span class="n">Q_ARG</span><span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QUrl</span><span style="color: #aa2211">>::</span><span class="n">iterator</span><span class="p">,</span> <span class="n">it</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #aa4000">return</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="p">}</span> <span style="color: #aa4000">else</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Move both <tt style="background: #ebebeb; font-size: 13px;">return</tt> to after the <tt style="background: #ebebeb; font-size: 13px;">if/else</tt>?</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D24962">https://phabricator.kde.org/D24962</a></div></div><br /><div><strong>To: </strong>meven, dfaure<br /><strong>Cc: </strong>kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>