Skip to content

Commit

Permalink
qt6: Convert music playlist parsing to QRegularExpression.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Mar 11, 2021
1 parent c608ee6 commit 1e95b5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions mythplugins/mythmusic/mythmusic/playlist.cpp
Expand Up @@ -1166,12 +1166,11 @@ void Playlist::cdrecordData(int fd)
// to update the same line, so I'm splitting it on \r or \n
// Track 01: 6 of 147 MB written (fifo 100%) [buf 99%] 16.3x.
QString data(buf);
static const QRegularExpression newline { "\\R" }; // Any unicode newline
#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
QStringList list = data.split(QRegExp("[\\r\\n]"),
QString::SkipEmptyParts);
QStringList list = data.split(newline, QString::SkipEmptyParts);
#else
QStringList list = data.split(QRegExp("[\\r\\n]"),
Qt::SkipEmptyParts);
QStringList list = data.split(newline, Qt::SkipEmptyParts);
#endif

for (int i = 0; i < list.size(); i++)
Expand Down
3 changes: 2 additions & 1 deletion mythplugins/mythmusic/mythmusic/pls.cpp
Expand Up @@ -16,6 +16,7 @@
#include <QMap>
#include <QStringList>
#include <QFileInfo>
#include <QRegularExpression>
#include <QSettings>
#include <QDomDocument>

Expand Down Expand Up @@ -107,7 +108,7 @@ int PlayListFile::parseM3U(PlayListFile *pls, const QString &filename)

QTextStream stream(&f);
QString data = stream.readAll();
QStringList lines = data.split(QRegExp("[\r\n]"));
QStringList lines = data.split(QRegularExpression("\\R")); // Any unicode newline

QStringList::iterator it;
for (it = lines.begin(); it != lines.end(); ++it)
Expand Down

0 comments on commit 1e95b5e

Please sign in to comment.