<table><tr><td style="">elvisangelaccio added a comment.</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/D2365" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>I think I figured out what's going on. This seems to be a regression introduced by <a href="https://phabricator.kde.org/rPLASMAINTEGRATION25be75542f831863e905b590b6429127df1b13d3" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;" rel="noreferrer">25be75542</a>. If I revert this commit, this test passes.</p>

<p>So, this is what's happening. In this example I'm considering the <tt style="background: #ebebeb; font-size: 13px;">text/x-chdr</tt> test case:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">The test calls <tt style="background: #ebebeb; font-size: 13px;">dialog.setMimeTypeFilters("text/x-chdr")</tt> and then <tt style="background: #ebebeb; font-size: 13px;">dialog.show()</tt></li>
<li class="remarkup-list-item"><tt style="background: #ebebeb; font-size: 13px;">KDEPlatformFileDialogHelper::show()</tt> calls <tt style="background: #ebebeb; font-size: 13px;">initializeDialog()</tt></li>
<li class="remarkup-list-item">In <tt style="background: #ebebeb; font-size: 13px;">initiliazeDialog()</tt> we end up appending <tt style="background: #ebebeb; font-size: 13px;">text/x-chdr</tt> to the filters of <tt style="background: #ebebeb; font-size: 13px;">m_fileWidget</tt>'s KFileFilterCombo (<tt style="background: #ebebeb; font-size: 13px;">d->m_filters</tt> in <tt style="background: #ebebeb; font-size: 13px;">kio.git/src/filewidgets/kfilefiltercombo.cpp</tt>)</li>
<li class="remarkup-list-item">In the test we call <tt style="background: #ebebeb; font-size: 13px;">dialog.selectMimeTypeFilter("text/x-chdr")</tt></li>
<li class="remarkup-list-item">QFileDialog calls <tt style="background: #ebebeb; font-size: 13px;">selectNameFilter("C header (*.h)")</tt></li>
<li class="remarkup-list-item">KDEPlatformFileDialogHelper calls <tt style="background: #ebebeb; font-size: 13px;">selectNameFilter(qt2KdeFilter(QStringList("C header (*.h)")))</tt></li>
<li class="remarkup-list-item">KDEPlatformFileDialog calls <tt style="background: #ebebeb; font-size: 13px;">filterWidget()->setCurrentFilter("*.h|C header ")</tt></li>
<li class="remarkup-list-item">The KFileFilterCombo ends up calling <tt style="background: #ebebeb; font-size: 13px;">setCurrentIndex(d->m_filters.indexOf("*.h|C header "))</tt> which fails because <tt style="background: #ebebeb; font-size: 13px;">d->m_filters</tt> contains only <tt style="background: #ebebeb; font-size: 13px;">text/x-chdr</tt>.</li>
<li class="remarkup-list-item"><tt style="background: #ebebeb; font-size: 13px;">dialog.selectedNameFilter()</tt> returns an empty string because of step 8.</li>
</ol>

<p>So the bug seems to be in the step 3. Before of commit <a href="https://phabricator.kde.org/rPLASMAINTEGRATION25be75542f831863e905b590b6429127df1b13d3" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;" rel="noreferrer">25be75542</a>, <tt style="background: #ebebeb; font-size: 13px;">d->m_filters</tt> would also receive <tt style="background: #ebebeb; font-size: 13px;">*.h|C header </tt> which would make the test pass.</p>

<p>But I'm still not sure how to properly fix this...</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>rPLASMAINTEGRATION Integration for Qt applications in Plasma</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D2365" rel="noreferrer">https://phabricator.kde.org/D2365</a></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>elvisangelaccio, dfaure, graesslin<br /><strong>Cc: </strong>plasma-devel, ali-mohamed, jensreuterberg, abetts, sebas<br /></div>