]> git.lyx.org Git - features.git/commit
Fix deprecation warnings from use of qSort()
authorScott Kostyshak <skostysh@lyx.org>
Thu, 5 Mar 2020 16:35:49 +0000 (11:35 -0500)
committerScott Kostyshak <skostysh@lyx.org>
Thu, 5 Mar 2020 17:44:39 +0000 (12:44 -0500)
commit14f369b47f9d05a27f3b854eeb7c5b7e79fd790f
tree28fd3b6d2e2215ab04cb533cc1852574ade7b73a
parent24926b2e2399624ca6a1290349e9070a0d880dee
Fix deprecation warnings from use of qSort()

This commit replaces qSort with std::sort to fix warnings from compiling with
Qt 5.14.1. Below is one of the warnings:

  error: ‘void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = QList<lyx::ColorCode>::iterator; LessT$
  an = bool (*)(lyx::ColorCode, lyx::ColorCode)]’ is deprecated: Use std::sort [-Werror=deprecated-declarations]

qSort() has been deprecated since Qt 5.2. Quoting from the ChangeLog [1]:

  With STL no longer being optional for building and using Qt, a number of
  parts of QtAlgorithms no longer make sense, and have therefore been
  deprecated. Replacements are available in the STL, and generally have
  much better performance

There are some cases that require more than just a trivial substitution, but
our code does not appear to use any of those cases.

For some discussion on the differences in speed of std::sort() and
qSort(), see the following:

  https://phabricator.kde.org/D10857

These are just warnings now, but will likely be errors with Qt 6:

  https://bugreports.qt.io/browse/QTBUG-73048

I tested that LyX can still be built against Qt 4.8.7 with this commit.

This commit follows 24926b2e, which also fixes some deprecation warnings.

[1]
https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.2.0/?h=v5.2.0
src/frontends/qt/GuiBox.cpp
src/frontends/qt/GuiCharacter.cpp
src/frontends/qt/GuiExternal.cpp
src/frontends/qt/GuiPrefs.cpp
src/frontends/qt/GuiRef.cpp