[LyX/master] Fix Qt deprecation warn for QList::fromSet()

Scott Kostyshak skostysh at lyx.org
Sat Mar 7 03:17:41 UTC 2020


commit 690c671b1d74aea566f7b4c952059afef2d4904a
Author: Scott Kostyshak <skostysh at lyx.org>
Date:   Fri Mar 6 21:04:15 2020 -0500

    Fix Qt deprecation warn for QList::fromSet()
    
    Fix the following warning from Qt 5.14.1:
    
      error: ‘static QList<T> QList<T>::fromSet(const QSet<T>&) [with T = QString]’ is deprecated: Use QList<T>(set.begin(), set.end()) instead. [-Werror=deprecated-declarations]
    
    Regarding QList::fromSet(), the documentation now states the
    following [1]:
    
      Since Qt 5.14, range constructors are available for Qt's generic
      container classes and should be used in place of this method.
    
    [1] https://doc.qt.io/qt-5/qlist.html
---
 src/frontends/qt/qt_helpers.cpp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index 0311b8b..f8cb247 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -335,8 +335,12 @@ QStringList texFileList(QString const & filename)
 			set.insert(qfile);
 	}
 
-	// remove duplicates
-	return QList<QString>::fromSet(set);
+        // remove duplicates
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+        return QList<QString>(set.begin(), set.end());
+#else
+        return QList<QString>::fromSet(set);
+#endif
 }
 
 QString const externalLineEnding(docstring const & str)


More information about the lyx-cvs mailing list