MimeData: Never detect anything as application/x-zerosize

- That mime type is pretty useless
- If there are two mime types that match a file by glob pattern, the mime
database implementation will find the best matching mime type by data of
*all* mime types and take that instead (this doesn't make sense btw).
That means that if .h is matched by c-hdr and c++-hdr, empty .h files are
detected as mime type application/x-zerosize, which is pretty useless

Change-Id: I4f9d532ef1efd29df00279c693486c92611485a8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
Eike Ziller
2015-02-18 14:36:34 +01:00
parent 73e2b0c579
commit 09716d64b3

View File

@@ -135,10 +135,10 @@ static inline bool isTextFile(const QByteArray &data)
MimeType MimeDatabasePrivate::findByData(const QByteArray &data, int *accuracyPtr) MimeType MimeDatabasePrivate::findByData(const QByteArray &data, int *accuracyPtr)
{ {
if (data.isEmpty()) { // if (data.isEmpty()) {
*accuracyPtr = 100; // *accuracyPtr = 100;
return mimeTypeForName(QLatin1String("application/x-zerosize")); // return mimeTypeForName(QLatin1String("application/x-zerosize"));
} // }
*accuracyPtr = 0; *accuracyPtr = 0;
MimeType candidate = provider()->findByMagic(data, accuracyPtr); MimeType candidate = provider()->findByMagic(data, accuracyPtr);