commit 14f369b47f9d05a27f3b854eeb7c5b7e79fd790f
Author: Scott Kostyshak <[email protected]>
Date:   Thu Mar 5 11:35:49 2020 -0500

    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       |    2 +-
 src/frontends/qt/GuiCharacter.cpp |    2 +-
 src/frontends/qt/GuiExternal.cpp  |    2 +-
 src/frontends/qt/GuiPrefs.cpp     |    2 +-
 src/frontends/qt/GuiRef.cpp       |   10 +++++-----
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/frontends/qt/GuiBox.cpp b/src/frontends/qt/GuiBox.cpp
index 6a991b5..67a1b0c 100644
--- a/src/frontends/qt/GuiBox.cpp
+++ b/src/frontends/qt/GuiBox.cpp
@@ -155,7 +155,7 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
 
        // the background can be uncolored while the frame cannot
        color_codes_ = colors();
-       qSort(color_codes_.begin(), color_codes_.end(), ColorSorter);
+       sort(color_codes_.begin(), color_codes_.end(), ColorSorter);
        fillComboColor(backgroundColorCO, true);
        fillComboColor(frameColorCO, false);
 
diff --git a/src/frontends/qt/GuiCharacter.cpp 
b/src/frontends/qt/GuiCharacter.cpp
index 59b7ca3..f06119a 100644
--- a/src/frontends/qt/GuiCharacter.cpp
+++ b/src/frontends/qt/GuiCharacter.cpp
@@ -237,7 +237,7 @@ GuiCharacter::GuiCharacter(GuiView & lv)
        bar    = barData();
        strike = strikeData();
        color  = colorData();
-       qSort(color.begin(), color.end(), ColorSorter);
+       sort(color.begin(), color.end(), ColorSorter);
 
        language = languageData();
        language.prepend(LanguagePair(qt_("Default"), "reset"));
diff --git a/src/frontends/qt/GuiExternal.cpp b/src/frontends/qt/GuiExternal.cpp
index 7be6be0..d850c2d 100644
--- a/src/frontends/qt/GuiExternal.cpp
+++ b/src/frontends/qt/GuiExternal.cpp
@@ -206,7 +206,7 @@ GuiExternal::GuiExternal(GuiView & lv)
                localizedTemplates.insert(qt_(i1->second.guiName), 
toqstr(i1->second.lyxName));
        // Sort alphabetically by (localized) GUI name
        QStringList keys = localizedTemplates.keys();
-       qSort(keys.begin(), keys.end(), SortLocaleAware);
+       sort(keys.begin(), keys.end(), SortLocaleAware);
        for (QString & key : keys) {
                QString const value = localizedTemplates[key];
                externalCO->addItem(key, value);
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index 7d269bc..6b00357 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -1089,7 +1089,7 @@ PrefColors::PrefColors(GuiPreferences * form)
                        continue;
                lcolors_.push_back(lc);
        }
-       qSort(lcolors_.begin(), lcolors_.end(), ColorSorter);
+       sort(lcolors_.begin(), lcolors_.end(), ColorSorter);
        vector<ColorCode>::const_iterator cit = lcolors_.begin();
        vector<ColorCode>::const_iterator const end = lcolors_.end();
        for (; cit != end; ++cit) {
diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp
index 6f3a342..7e98e48 100644
--- a/src/frontends/qt/GuiRef.cpp
+++ b/src/frontends/qt/GuiRef.cpp
@@ -490,8 +490,8 @@ void GuiRef::redoRefs()
                }
        }
        // sort categories case-intensively
-       qSort(refsCategories.begin(), refsCategories.end(),
-             caseInsensitiveLessThan /*defined above*/);
+       sort(refsCategories.begin(), refsCategories.end(),
+                 caseInsensitiveLessThan /*defined above*/);
        if (noprefix)
                refsCategories.insert(0, qt_("<No prefix>"));
 
@@ -499,10 +499,10 @@ void GuiRef::redoRefs()
                                
sortingCO->itemData(sortingCO->currentIndex()).toString()
                                : QString();
        if (sort == "nocase")
-               qSort(refsStrings.begin(), refsStrings.end(),
-                     caseInsensitiveLessThan /*defined above*/);
+               std::sort(refsStrings.begin(), refsStrings.end(),
+                         caseInsensitiveLessThan /*defined above*/);
        else if (sort == "case")
-               qSort(refsStrings.begin(), refsStrings.end());
+               std::sort(refsStrings.begin(), refsStrings.end());
 
        if (groupCB->isChecked()) {
                QList<QTreeWidgetItem *> refsCats;
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to