From ab38cf0e059c15af82da7e48045823a5cbbb5d52 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Sun, 17 May 2026 09:28:30 +0200 Subject: Improve code for reading text files line-by-line --- src/pluginlist.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 6b4c9281..021b5f5b 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -704,10 +704,11 @@ void PluginList::readLockedOrderFrom(const QString& fileName) return; } - file.open(QIODevice::ReadOnly); + file.open(QIODevice::ReadOnly | QIODevice::Text); + const QByteArray contents = file.readAll(); + file.close(); int lineNumber = 0; - while (!file.atEnd()) { - QByteArray line = file.readLine(); + for (const QByteArray& line : contents.split('\n')) { ++lineNumber; // Skip empty lines or commented out lines (#) @@ -782,8 +783,7 @@ void PluginList::readLockedOrderFrom(const QString& fileName) m_LockedOrder[pluginName] = priority; continue; } - } /* while (!file.atEnd()) */ - file.close(); + } } void PluginList::writeLockedOrder(const QString& fileName) const -- cgit v1.3.1