From f2e8a81227b3ee09afe1bf8a5d292e8c5f2ee67f Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 21 Feb 2013 12:11:35 +0100 Subject: [PATCH] QMimeDatabase: pass MatchMode down, to fix MatchContent. Task-number: QTBUG-29702 Change-Id: I2f1538adbf8e7a5edfc4276585bf4ef04ce69874 Reviewed-by: Konstantin Ritt Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimedatabase.cpp | 2 +- .../corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index d8b7a02a1b..a5f5a326d4 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -418,7 +418,7 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode } else { // Implemented as a wrapper around mimeTypeForFile(QFileInfo), so no mutex. QFileInfo fileInfo(fileName); - return mimeTypeForFile(fileInfo); + return mimeTypeForFile(fileInfo, mode); } } diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 79d8b3dfe4..a90bfadd73 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -442,6 +442,8 @@ void tst_QMimeDatabase::mimeTypeForFileWithContent() txtTempFile.close(); mime = db.mimeTypeForFile(txtTempFileName); QCOMPARE(mime.name(), QString::fromLatin1("text/plain")); + mime = db.mimeTypeForFile(txtTempFileName, QMimeDatabase::MatchContent); + QCOMPARE(mime.name(), QString::fromLatin1("application/smil")); } // Test what happens with an incorrect path @@ -714,6 +716,8 @@ void tst_QMimeDatabase::findByData() QFileInfo info(filePath); QString mimeForInfo = database.mimeTypeForFile(info, QMimeDatabase::MatchContent).name(); QCOMPARE(mimeForInfo, resultMimeTypeName); + QString mimeForFile = database.mimeTypeForFile(filePath, QMimeDatabase::MatchContent).name(); + QCOMPARE(mimeForFile, resultMimeTypeName); } void tst_QMimeDatabase::findByFile_data()