<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/D26432">View Revision</a></tr></table><br /><div><div><p>Oh boy this is going to really give a big conflict with <a href="https://phabricator.kde.org/D26202" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D26202</a>!</p>

<p>Given that this commit is "more trivial" than <a href="https://phabricator.kde.org/D26202" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D26202</a>, maybe it should happen again *after* <a href="https://phabricator.kde.org/D26202" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D26202</a> lands...</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/D26432#inline-148815">View Inline</a><span style="color: #4b4d51; font-weight: bold;">anthonyfieroni</span> wrote in <span style="color: #4b4d51; font-weight: bold;">kconfigtest.cpp:533-542</span></div>
<div style="margin: 8px 0; padding: 0 12px; color: #74777D;"><p style="padding: 0; margin: 8px;">When it has only strings you can use <tt style="background: #ebebeb; font-size: 13px;">R"()"</tt><br />
<a href="https://en.cppreference.com/w/cpp/language/string_literal" class="remarkup-link" target="_blank" rel="noreferrer">https://en.cppreference.com/w/cpp/language/string_literal</a></p></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">What would be the benefit here? One double-backslash simplified to a single one, and that's it, right?</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/D26432#inline-148853">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kconfig_compiler.cpp:694</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">defaultValue</span> <span style="color: #aa2211">=</span> <span class="n">QLatin1String</span><span class="p">(</span><span style="color: #766510">"default"</span><span class="p">)</span> <span style="color: #aa2211">+</span> <span class="n">name</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">
</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">cpp</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">flush</span></span><span class="bright"></span><span class="p"><span class="bright">();</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; ">    <span class="p">}</span> <span style="color: #aa4000">else</span> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">type</span> <span style="color: #aa2211">==</span> <span class="n">QLatin1String</span><span class="p">(</span><span style="color: #766510">"Color"</span><span class="p">)</span> <span style="color: #aa2211">&&</span> <span style="color: #aa2211">!</span><span class="n">defaultValue</span><span class="p">.</span><span class="n">isEmpty</span><span class="p">())</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Why? Surely the QTextStream destructor (which is called here) will take care of that.</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/D26432#inline-148852">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kconfig_compiler.cpp:729</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">defaultValue</span> <span style="color: #aa2211">=</span> <span class="n">QLatin1String</span><span class="p">(</span><span style="color: #766510">"default"</span><span class="p">)</span> <span style="color: #aa2211">+</span> <span class="n">name</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">cpp</span><span class="p">.</span><span class="n">flush</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">    <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">(same)</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/D26432#inline-148854">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kconfig_compiler.cpp:881</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="p">}</span> <span style="color: #aa4000">else</span> <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">name</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span style="color: #766510">' '</span><span class="p">))</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">cout</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright"><<</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">"Entry '"</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">name</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright"><<</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">"' contains spaces! <name> elements can not contain spaces!"</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright"><<</span></span><span class="bright"> </span><span class="n">endl</span><span class="p">;</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">std</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">cout</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright"><<</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">"Entry '"</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">qPrintable</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">name</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright"><<</span></span><span class="bright"> </span><span style="color: #766510"><span class="bright">"' contains spaces! <name> elements can not contain spaces!"</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">std</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">::</span></span><span class="n">endl</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; ">        <span class="n">name</span><span class="p">.</span><span class="n">remove</span><span class="p">(</span><span style="color: #766510">' '</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">(pre-existing) Strange that this one is cout and not cerr...</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/D26432#inline-148861">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kconfig_compiler.cpp:1379</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="n">out</span> <span style="color: #aa2211"><<</span> <span style="color: #766510">";<span class="bright">"</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">endl</span></span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">out</span> <span style="color: #aa2211"><<</span> <span style="color: #766510">";<span class="bright"></span></span><span class="bright"></span><span style="color: #bb6622"><span class="bright">\n</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"</span></span><span class="p">;</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">out</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">flush</span></span><span class="bright"></span><span class="p"><span class="bright">();</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; ">    <span style="color: #aa4000">return</span> <span class="n">result</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I've been wondering if this flush() is needed.</p>

<p style="padding: 0; margin: 8px;">In my tests, it works without. <a href="http://www.davidfaure.fr/2020/qtextstream_flush.cpp" class="remarkup-link" target="_blank" rel="noreferrer">http://www.davidfaure.fr/2020/qtextstream_flush.cpp</a><br />
QTextStream is notified of the QString being deleted, and flushes.</p>

<p style="padding: 0; margin: 8px;">But in theory local variables are deleted *after* the return value is copied (otherwise mutex lockers wouldn't make sense, stack overflow confirms) so in the absence of named-return-value-optimization (which IIRC is only guaranteed in C++17 and later), the copying could happen before the flushing.</p>

<p style="padding: 0; margin: 8px;">Unless I missed something, let's keep the <tt style="background: #ebebeb; font-size: 13px;">flush()</tt> to be safe :-)</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R237 KConfig</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D26432">https://phabricator.kde.org/D26432</a></div></div><br /><div><strong>To: </strong>mlaurent, dfaure, tcanabrava<br /><strong>Cc: </strong>anthonyfieroni, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>