From 4617faa7fae3deda5690dade4b64785ac215e16c Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@edeltech.ch>
Date: Thu, 21 Jun 2018 00:19:26 +0200
Subject: [PATCH] Migrate QGstUtils to use QRegularExpression

This patch updates the QGstUtils class to use QRegularExpression in
place of QRegExp which is to be considered deprecated.

Fixes: QTBUG-72589
Change-Id: I67e189c48688b512cc76c884fd2a7e51e1b188f9
Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io>
---
 src/gsttools/qgstutils.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp
index 6960ff8f4..24372f7ae 100644
--- a/src/gsttools/qgstutils.cpp
+++ b/src/gsttools/qgstutils.cpp
@@ -44,6 +44,7 @@
 #include <QtCore/qdir.h>
 #include <QtCore/qbytearray.h>
 #include <QtCore/qvariant.h>
+#include <QtCore/qregularexpression.h>
 #include <QtCore/qsize.h>
 #include <QtCore/qset.h>
 #include <QtCore/qstringlist.h>
@@ -804,7 +805,7 @@ QSet<QString> QGstUtils::supportedMimeTypes(bool (*isValidFactory)(GstElementFac
                             if (value) {
                                 gchar *str = gst_value_serialize(value);
                                 QString versions = QLatin1String(str);
-                                const QStringList elements = versions.split(QRegExp(QLatin1String("\\D+")), QString::SkipEmptyParts);
+                                const QStringList elements = versions.split(QRegularExpression(QLatin1String("\\D+")), QString::SkipEmptyParts);
                                 for (const QString &e : elements)
                                     supportedMimeTypes.insert(nameLowcase + e);
                                 g_free(str);
@@ -1466,10 +1467,11 @@ QString QGstUtils::fileExtensionForMimeType(const QString &mimeType)
     if (!extension.isEmpty() || format.isEmpty())
         return extension;
 
-    QRegExp rx(QStringLiteral("[-/]([\\w]+)$"));
+    QRegularExpression rx(QStringLiteral("[-/]([\\w]+)$"));
+    QRegularExpressionMatch match = rx.match(format);
 
-    if (rx.indexIn(format) != -1)
-        extension = rx.cap(1);
+    if (match.hasMatch())
+        extension = match.captured(1);
 
     return extension;
 }
-- 
GitLab