[neon/qt/qtbase/Neon/release] debian: Revert "Remove the qmimeprovider.cpp part of mime_globs.diff."

Dmitry Shachnev null at kde.org
Thu May 5 10:59:24 BST 2022


Git commit 4f11833b4405f0239564fa597ae271f0c7cea7ab by Dmitry Shachnev.
Committed on 16/06/2021 at 17:12.
Pushed by jriddell into branch 'Neon/release'.

Revert "Remove the qmimeprovider.cpp part of mime_globs.diff."

See the discussion in https://bugs.debian.org/989744 for details.

This reverts commit 75c663da63357893beddeccfe53abff68a0ec568.

M  +0    -4    debian/changelog
M  +35   -1    debian/patches/mime_globs.diff

https://invent.kde.org/neon/qt/qtbase/commit/4f11833b4405f0239564fa597ae271f0c7cea7ab

diff --git a/debian/changelog b/debian/changelog
index a743fba..33450fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,5 @@
 qtbase-opensource-src (5.15.2+dfsg-8) UNRELEASED; urgency=medium
 
-  [ Dmitry Shachnev ]
-  * Remove the qmimeprovider.cpp part of mime_globs.diff. It is unrelated to
-    the original purpose of that patch, and causes problems with all/allfiles
-    MIME type (closes: #989744).
 
  -- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>  Sat, 12 Jun 2021 20:32:46 +0300
 
diff --git a/debian/patches/mime_globs.diff b/debian/patches/mime_globs.diff
index 1c66eba..d5bb271 100644
--- a/debian/patches/mime_globs.diff
+++ b/debian/patches/mime_globs.diff
@@ -2,8 +2,14 @@ Description: adjust QMimeDatabase implementation
  When multiple globs match, and the result from magic sniffing is
  unrelated to any of those globs, globs have priority and one of them
  should be picked up.
+ .
+ This change also optimizes QMimeBinaryProvider::addFileNameMatches
+ to have the same logic as xdgmime for glob matching:
+ literals > extensions > other globs
+ As soon as one category matches, we can stop there.
+ This makes no difference in the overall results, in practice.
 Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=0cbbba2aa5b47224
-Last-Update: 2021-06-12
+Last-Update: 2021-05-18
 
 --- a/src/corelib/mimetypes/qmimedatabase.cpp
 +++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -49,3 +55,31 @@ Last-Update: 2021-06-12
          m_knownSuffixLength = knownSuffixLength;
      }
  }
+--- a/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMat
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)



More information about the Neon-commits mailing list