Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
None
-
5.0.0, 5.0.1
-
None
-
f2e8a81227b3ee09afe1bf8a5d292e8c5f2ee67f
Description
QMimeType QMimeDatabase::mimeTypeForFile(const QString & fileName, MatchMode mode = MatchDefault) const
does not work properly for QMimeDatabase::MatchContent. It will use MatchDefault instead.
You can see in the following code that if mode is not MatchExtension, it passes through to the mimeTypeForFile( const QFileInfo & fileInfo, MatchMode mode = MatchDefault) version but it doesn't pass along the mode argument which defaults to MatchDefault. Passing the mode argument to the QFileInfo version should fix the problem.
QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode) const
{
if (mode == MatchExtension) {
QMutexLocker locker(&d->mutex);
QStringList matches = d->mimeTypeForFileName(fileName);
const int matchCount = matches.count();
if (matchCount == 0)
else if (matchCount == 1)
{ return d->mimeTypeForName(matches.first()); }else
{ // We have to pick one. matches.sort(); // Make it deterministic return d->mimeTypeForName(matches.first()); }} else
{ // Implemented as a wrapper around mimeTypeForFile(QFileInfo), so no mutex. QFileInfo fileInfo(fileName); return mimeTypeForFile(fileInfo); }}
Attachments
For Gerrit Dashboard: QTBUG-29702 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
48578,1 | QMimeDatabase: pass MatchMode down, to fix MatchContent. | stable | qt/qtbase | Status: MERGED | +2 | 0 |