Skip to content

Commit

Permalink
Fix Deprecation warnings coming with Qt 5.15
Browse files Browse the repository at this point in the history
* fix 383 warnings C4996 (deprecated) with one single line change
* fix 5 'empty' warnings about invalid slots, not sure the remaining
slots serve any purpose though
* disable warnings C4127 and C4996 for thirdparty/google_analytics
* fix 30 warnings C4996 using the suggested alternatives available since
at least Qt 5.9, so won't break building against that
* change as requested in code review plus some more fixes using the same
idea
* fixing yet more warnings
* disable deprecation warnings in qoogle_analytics for MinGW too
although I believe maxOS and Linux may use those too. Easy to extend to
those, if need be.
* Fix qml runtime warnings exactly following the advice given by that
warning, but without really know what I'm doing here or whether that is
still backwards compatible to Qt 5.9.
* Use replacements as suggested, if available and no `endl` neded with
`qDebug()`
* fix 24 more
* 2 more
* 7 more (one only seen in DEBUG mode)
* Fix the `endl` warnings
* maybe more changes this way?
* Add all warnings C5999 or bigger to the ignore list for telemetry
with Qt 5.15 Beta 1 as avoiding only C26439, C26444,C 26452, C26495,
C26498, C26812 isn't possible
* fix 2 deprecation warning new with Qt 5.15 beta 1
* fix 4 new warnings and also Qt 5.12 builds, disable some dead code
* fix deprecation warnings new with Qt 5.15's MSVC 2019 integration and
revert some (`QNetworkReply::networkError()`) that Qt 5.15 beta 2
reverted too
* fix warning reg. obsolete operator < for QVariants
* revert changes needed prior to beta 3 And clarifying some earlier
changes
* mark ToDos
  • Loading branch information
Jojo-Schmitz committed May 7, 2020
1 parent f579e6c commit 9077769
Show file tree
Hide file tree
Showing 94 changed files with 343 additions and 251 deletions.
2 changes: 1 addition & 1 deletion audio/midi/fluid/sfont.cpp
Expand Up @@ -785,7 +785,7 @@ bool SFont::load()
}
f.close();
/* sort preset list by bank, preset # */
qSort(presets.begin(), presets.end(), preset_compare);
std::sort(presets.begin(), presets.end(), preset_compare);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion audio/midi/midifile.cpp
Expand Up @@ -907,7 +907,7 @@ void MidiFile::separateChannel()
int nn = channel.size();
if (nn <= 1)
continue;
qSort(channel);
std::sort(channel.begin(), channel.end());
// -- split --
// insert additional tracks, assign to them found channels
for (int ii = 1; ii < nn; ++ii) {
Expand Down
2 changes: 1 addition & 1 deletion avsomr/ui/recognitionproccessdialog.h
Expand Up @@ -54,7 +54,7 @@ class RecognitionProccessDialog : private QProgressDialog
IAvsOmrRecognizer::Step _lastStep;

QTimer _updater;
QTime _time;
QElapsedTimer _time;
QPushButton* _closeBtn{nullptr};
TaskbarProgress* _taskbarProgress{nullptr};
};
Expand Down
2 changes: 1 addition & 1 deletion awl/aslider.cpp
Expand Up @@ -127,7 +127,7 @@ void AbstractSlider::wheelEvent(QWheelEvent* ev)
int div = 50;
if (ev->modifiers() & Qt::ShiftModifier)
div = 15;
_value += (ev->delta() * lineStep()) / div;
_value += (ev->angleDelta().y() * lineStep()) / div;
if (_value < _minValue)
_value = _minValue;
else if (_value > _maxValue)
Expand Down
7 changes: 6 additions & 1 deletion awl/pitchlabel.cpp
Expand Up @@ -58,8 +58,13 @@ QSize PitchLabel::sizeHint() const
QFontMetrics fm(font());
int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int h = fm.height() + fw * 2;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
// int w = 2 + fm.horizontalAdvance(QString("A#8")) + fw * 4;
int w = 2 + fm.horizontalAdvance(QString("-9999")) + fw * 4; // must display 14Bit controller values
#else
// int w = 2 + fm.width(QString("A#8")) + fw * 4;
int w = 2 + fm.width(QString("-9999")) + fw * 4; // must display 14Bit controller values
#endif
return QSize(w, h).expandedTo(QApplication::globalStrut());
}

Expand All @@ -76,7 +81,7 @@ void PitchLabel::setValue(int val)
if (_pitchMode)
s = pitch2string(_value);
else
s.sprintf("%d", _value);
s = QString::asprintf("%d", _value);
setText(s);
}

Expand Down
11 changes: 9 additions & 2 deletions awl/poslabel.cpp
Expand Up @@ -69,10 +69,17 @@ QSize PosLabel::sizeHint() const
int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int h = fm.height() + fw * 2;
int w;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
if (_smpte)
w = 2 + fm.horizontalAdvance('9') * 9 + fm.horizontalAdvance(':') * 3 + fw * 4;
else
w = 2 + fm.horizontalAdvance('9') * 9 + fm.horizontalAdvance('.') * 2 + fw * 4;
#else
if (_smpte)
w = 2 + fm.width('9') * 9 + fm.width(':') * 3 + fw * 4;
else
w = 2 + fm.width('9') * 9 + fm.width('.') * 2 + fw * 4;
#endif
return QSize(w, h).expandedTo(QApplication::globalStrut());
}

Expand All @@ -88,12 +95,12 @@ void PosLabel::updateValue()
if (_smpte) {
int min, sec, frame, subframe;
pos.msf(&min, &sec, &frame, &subframe);
s.sprintf("%03d:%02d:%02d:%02d", min, sec, frame, subframe);
s = QString::asprintf("%03d:%02d:%02d:%02d", min, sec, frame, subframe);
}
else {
int measure, beat, tick;
pos.mbt(&measure, &beat, &tick);
s.sprintf("%04d.%02d.%03u", measure+1, beat+1, tick);
s = QString::asprintf("%04d.%02d.%03u", measure+1, beat+1, tick);
}
setText(s);
}
Expand Down
2 changes: 1 addition & 1 deletion awl/utils.cpp
Expand Up @@ -60,7 +60,7 @@ QString pitch2string(int v)
return QString("----");
int octave = (v / 12) - 1;
QString o;
o.sprintf("%d", octave);
o = QString::asprintf("%d", octave);
int i = v % 12;
return qApp->translate("awlutils", octave < 0 ? valu[i] : vall[i]) + o;
}
Expand Down
2 changes: 1 addition & 1 deletion importexport/bww/parser.cpp
Expand Up @@ -204,7 +204,7 @@ static void determineTimesig(QList<Bww::MeasureDescription> const& measures, int
QMap<int, int>::const_iterator i = map.constBegin();
while (i != map.constEnd())
{
qDebug() << "measureDurations:" << i.key() << i.value() << endl;
qDebug() << "measureDurations:" << i.key() << i.value();
if (i.value() > max)
{
commonDur = i.key();
Expand Down
4 changes: 4 additions & 0 deletions importexport/guitarpro/importgtp-gp6.cpp
Expand Up @@ -2318,7 +2318,11 @@ void GuitarPro6::readMasterBars(GPPartInfo* partInfo)
currentFermata = currentFermata.nextSibling();

// get the fermata information and construct a gpFermata from them
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList fermataComponents = fermata.split("/", Qt::SkipEmptyParts);
#else
QStringList fermataComponents = fermata.split("/", QString::SkipEmptyParts);
#endif
GPFermata gpFermata;
gpFermata.index = fermataComponents.at(0).toInt();
gpFermata.timeDivision = fermataComponents.at(1).toInt();
Expand Down
5 changes: 5 additions & 0 deletions importexport/guitarpro/importgtp.cpp
Expand Up @@ -738,8 +738,13 @@ void GuitarPro::readLyrics()
QString lyrics = readWordPascalString();
lyrics.replace(QRegExp("\n"), " ");
lyrics.replace(QRegExp("\r"), " ");
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
auto sl = lyrics.split(" ", Qt::KeepEmptyParts);
//gpLyrics.lyrics = lyrics.split(" ", Qt::KeepEmptyParts);
#else
auto sl = lyrics.split(" ", QString::KeepEmptyParts);
//gpLyrics.lyrics = lyrics.split(" ", QString::KeepEmptyParts);
#endif
for (auto& str : sl) {
/*while (str[0] == '-')
{
Expand Down
8 changes: 4 additions & 4 deletions importexport/midiimport/importmidi_chord.cpp
Expand Up @@ -105,9 +105,9 @@ ReducedFraction maxNoteLen(const std::pair<const ReducedFraction, MidiChord> &ch

void removeOverlappingNotes(QList<MidiNote> &notes)
{
QLinkedList<MidiNote> tempNotes;
std::list<MidiNote> tempNotes;
for (const auto &note: notes)
tempNotes.append(note);
tempNotes.push_back(note);

for (auto noteIt1 = tempNotes.begin(); noteIt1 != tempNotes.end(); ++noteIt1) {
for (auto noteIt2 = std::next(noteIt1); noteIt2 != tempNotes.end(); ) {
Expand Down Expand Up @@ -410,7 +410,7 @@ void sortNotesByPitch(std::multimap<ReducedFraction, MidiChord> &chords)
for (auto &chordEvent: chords) {
// in each chord sort notes by pitches
auto &notes = chordEvent.second.notes;
qSort(notes.begin(), notes.end(), pitchSort);
std::sort(notes.begin(), notes.end(), pitchSort);
}
}

Expand All @@ -426,7 +426,7 @@ void sortNotesByLength(std::multimap<ReducedFraction, MidiChord> &chords)
for (auto &chordEvent: chords) {
// in each chord sort notes by lengths
auto &notes = chordEvent.second.notes;
qSort(notes.begin(), notes.end(), lenSort);
std::sort(notes.begin(), notes.end(), lenSort);
}
}

Expand Down
2 changes: 1 addition & 1 deletion importexport/midiimport/importmidi_model.cpp
Expand Up @@ -944,7 +944,7 @@ Qt::ItemFlags TracksModel::editableFlags(int row, int col) const
Qt::ItemFlags TracksModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return {};

Qt::ItemFlags flags = Qt::ItemFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
const int trackIndex = trackIndexFromRow(index.row());
Expand Down
4 changes: 4 additions & 0 deletions importexport/musedata/musedata.cpp
Expand Up @@ -48,7 +48,11 @@ namespace Ms {

void MuseData::musicalAttribute(QString s, Part* part)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList al = s.mid(3).split(" ", Qt::SkipEmptyParts);
#else
QStringList al = s.mid(3).split(" ", QString::SkipEmptyParts);
#endif
foreach(QString item, al) {
if (item.startsWith("K:")) {
int key = item.mid(2).toInt();
Expand Down
5 changes: 5 additions & 0 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -911,6 +911,7 @@ static void handleTupletStop(Tuplet*& tuplet, const int normalNotes)
// setElementPropertyFlags
//---------------------------------------------------------

// ToDo for Qt 5.15: QString::null vs. QString() ??
static void setElementPropertyFlags(ScoreElement* element, const Pid propertyId,
const QString value1, const QString value2 = QString::null)
{
Expand Down Expand Up @@ -3303,7 +3304,11 @@ void MusicXMLParserPass2::doEnding(const QString& partId, Measure* measure,
else if (type.isEmpty())
_logger->logError("empty ending type", &_e);
else {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = number.split(",", Qt::SkipEmptyParts);
#else
QStringList sl = number.split(",", QString::SkipEmptyParts);
#endif
QList<int> iEndingNumbers;
bool unsupported = false;
foreach(const QString &s, sl) {
Expand Down
4 changes: 2 additions & 2 deletions importexport/musicxml/importxml.cpp
Expand Up @@ -184,8 +184,8 @@ static bool extractRootfile(QFile* qf, QByteArray& data)

static Score::FileError doValidate(const QString& name, QIODevice* dev)
{
QTime t;
t.start();
//QElapsedTimer t;
//t.start();

// initialize the schema
ValidatorMessageHandler messageHandler;
Expand Down
10 changes: 9 additions & 1 deletion importexport/ove/ove.cpp
Expand Up @@ -3039,7 +3039,11 @@ QString NumericEnding::getText() const {

QList<int> NumericEnding::getNumbers() const {
int i;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList strs = text_.split(",", Qt::SkipEmptyParts);
#else
QStringList strs = text_.split(",", QString::SkipEmptyParts);
#endif
QList<int> endings;

for (i = 0; i < strs.size(); ++i) {
Expand Down Expand Up @@ -7288,7 +7292,11 @@ void LyricChunkParse::processLyricInfo(const LyricInfo& info) {
bool changeMeasure = true;
MeasureData* measureData = 0;
int trackMeasureCount = ove_->getTrackBarCount();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList words = info.lyric_.split(" ", Qt::SkipEmptyParts);
#else
QStringList words = info.lyric_.split(" ", QString::SkipEmptyParts);
#endif

while ( index < words.size() && measureId+1 < trackMeasureCount ) {
if( changeMeasure ) {
Expand Down Expand Up @@ -7646,7 +7654,7 @@ void OveOrganizer::organizeContainers(int /*part*/, int /*track*/,
}

// shift voices
qSort(voices.begin(), voices.end());
std::sort(voices.begin(), voices.end());

for (i = 0; i < voices.size(); ++i) {
int voice = voices[i];
Expand Down
12 changes: 12 additions & 0 deletions libmscore/chordlist.cpp
Expand Up @@ -30,7 +30,11 @@ HChord::HChord(const QString& str)
{ "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" }
};
keys = 0;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = str.split(" ", Qt::SkipEmptyParts);
#else
QStringList sl = str.split(" ", QString::SkipEmptyParts);
#endif
for (const QString& s : sl) {
for (int i = 0; i < 12; ++i) {
if (s == scaleNames[0][i] || s == scaleNames[1][i]) {
Expand Down Expand Up @@ -294,10 +298,18 @@ void HChord::add(const QList<HDegree>& degreeList)
static void readRenderList(QString val, QList<RenderAction>& renderList)
{
renderList.clear();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = val.split(" ", Qt::SkipEmptyParts);
#else
QStringList sl = val.split(" ", QString::SkipEmptyParts);
#endif
for (const QString& s : sl) {
if (s.startsWith("m:")) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList ssl = s.split(":", Qt::SkipEmptyParts);
#else
QStringList ssl = s.split(":", QString::SkipEmptyParts);
#endif
if (ssl.size() == 3) {
// m:x:y
RenderAction a;
Expand Down
2 changes: 1 addition & 1 deletion libmscore/element.h
Expand Up @@ -131,7 +131,7 @@ class EditData {
bool vRaster { false };

int key { 0 };
Qt::KeyboardModifiers modifiers { 0 };
Qt::KeyboardModifiers modifiers { /*0*/ }; // '0' initialized via default constructor, doing it here too results in compiler warning with Qt 5.15
QString s;

Qt::MouseButtons buttons { Qt::NoButton };
Expand Down
4 changes: 4 additions & 0 deletions libmscore/figuredbass.cpp
Expand Up @@ -1312,7 +1312,11 @@ void FiguredBass::endEdit(EditData& ed)
return;

// split text into lines and create an item for each line
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList list = txt.split("\n", Qt::SkipEmptyParts);
#else
QStringList list = txt.split('\n', QString::SkipEmptyParts);
#endif
qDeleteAll(items);
items.clear();
QString normalizedText = QString();
Expand Down
4 changes: 4 additions & 0 deletions libmscore/harmony.cpp
Expand Up @@ -2022,7 +2022,11 @@ QString Harmony::generateScreenReaderInfo() const
aux = aux.replace("#", QObject::tr("♯")).replace("<", "");
QString extension = "";

#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
for (QString s : aux.split(">", Qt::SkipEmptyParts)) {
#else
for (QString s : aux.split(">", QString::SkipEmptyParts)) {
#endif
if (!s.contains("blues"))
s.replace("b", QObject::tr("♭"));
extension += s + " ";
Expand Down
10 changes: 5 additions & 5 deletions libmscore/layout.cpp
Expand Up @@ -222,7 +222,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)

// layout upstem noteheads
if (upVoices > 1) {
qSort(upStemNotes.begin(), upStemNotes.end(),
std::sort(upStemNotes.begin(), upStemNotes.end(),
[](Note* n1, const Note* n2) ->bool {return n1->line() > n2->line(); } );
}
if (upVoices) {
Expand All @@ -232,7 +232,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)

// layout downstem noteheads
if (downVoices > 1) {
qSort(downStemNotes.begin(), downStemNotes.end(),
std::sort(downStemNotes.begin(), downStemNotes.end(),
[](Note* n1, const Note* n2) ->bool {return n1->line() > n2->line(); } );
}
if (downVoices) {
Expand Down Expand Up @@ -349,7 +349,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
else
break;
}
qSort(overlapNotes.begin(), overlapNotes.end(),
std::sort(overlapNotes.begin(), overlapNotes.end(),
[](Note* n1, const Note* n2) ->bool {return n1->line() > n2->line(); } );

// determine nature of overlap
Expand Down Expand Up @@ -567,7 +567,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
if (downVoices)
notes.insert(notes.end(), downStemNotes.begin(), downStemNotes.end());
if (upVoices + downVoices > 1)
qSort(notes.begin(), notes.end(),
std::sort(notes.begin(), notes.end(),
[](Note* n1, const Note* n2) ->bool {return n1->line() > n2->line(); } );
layoutChords3(notes, staff, segment);
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ void Score::layoutChords3(std::vector<Note*>& notes, const Staff* staff, Segment
}
nAcc = umi.size();
if (nAcc > 1)
qSort(umi);
std::sort(umi.begin(), umi.end());

// lay out columns
for (int i = 0; i < nColumns; ++i) {
Expand Down
4 changes: 4 additions & 0 deletions libmscore/lyrics.cpp
Expand Up @@ -381,7 +381,11 @@ void Lyrics::paste(EditData& ed)
#endif
QString txt = QApplication::clipboard()->text(mode);
QString regex = QString("[^\\S") + QChar(0xa0) + QChar(0x202F) + "]+";
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = txt.split(QRegExp(regex), Qt::SkipEmptyParts);
#else
QStringList sl = txt.split(QRegExp(regex), QString::SkipEmptyParts);
#endif
if (sl.empty())
return;

Expand Down
2 changes: 1 addition & 1 deletion libmscore/mscoreview.cpp
Expand Up @@ -74,7 +74,7 @@ const QList<Element*> MuseScoreView::elementsAt(const QPointF& p)
Page* page = point2page(p);
if (page) {
el = page->items(p - page->pos());
qSort(el.begin(), el.end(), elementLower);
std::sort(el.begin(), el.end(), elementLower);
}
return el;
}
Expand Down

0 comments on commit 9077769

Please sign in to comment.