Skip to content

Commit

Permalink
Fix Deprecation warnings with Qt 5.15 (and 5.14)
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
* fix warning reg QString()::null
* fix a 'regression' from a revert of an earlier change
  • Loading branch information
Jojo-Schmitz committed Jun 3, 2020
1 parent 9714c8e commit 6a71eb2
Show file tree
Hide file tree
Showing 95 changed files with 360 additions and 263 deletions.
2 changes: 1 addition & 1 deletion audio/midi/fluid/sfont.cpp
Expand Up @@ -824,7 +824,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 @@ -914,7 +914,7 @@ void MidiFile::separateChannel()
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 @@ -53,7 +53,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 @@ -128,7 +128,7 @@ void AbstractSlider::wheelEvent(QWheelEvent* ev)
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 @@ -57,8 +57,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
12 changes: 10 additions & 2 deletions awl/poslabel.cpp
Expand Up @@ -68,11 +68,19 @@ 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 @@ -89,11 +97,11 @@ 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)
}
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 framework/telemetry/CMakeLists.txt
Expand Up @@ -43,6 +43,6 @@ target_link_libraries(${MODULE} global google_analytics)

if (MSVC)
set_target_properties (${MODULE} PROPERTIES
COMPILE_FLAGS "/wd4127"
COMPILE_FLAGS "/wd4127 /wd26439 /wd5999" # ToDo for Qt 5.15: "... /wd26444 /wd26451 /wd26495 /wd26498 /wd26812" ??
)
endif (MSVC)
1 change: 1 addition & 0 deletions framework/telemetry/widgets/telemetrypermissiondialog.cpp
Expand Up @@ -35,6 +35,7 @@ TelemetryPermissionDialog::TelemetryPermissionDialog(QQmlEngine* engine)

setFlags(Qt::Dialog | Qt::CustomizeWindowHint); ///@note Hidding a native frame with 'X' close button

// ToDo for Qt 5.15: QDesktopWidget::availableGeometry() vs. QGuiApplication::screens() ??
QRect desktopRect = QApplication::desktop()->availableGeometry();
QPoint center = desktopRect.center();

Expand Down
2 changes: 1 addition & 1 deletion global/gui/miconengine.cpp
Expand Up @@ -221,7 +221,7 @@ QPixmap MIconEngine::pixmap(const QSize& size, QIcon::Mode mode, QIcon::State st
QString pmckey(d->pmcKey(size, mode, state));
pmckey.prepend("Ms");

if (QPixmapCache::find(pmckey, pm)) {
if (QPixmapCache::find(pmckey, &pm)) {
return pm;
}

Expand Down
2 changes: 1 addition & 1 deletion importexport/bww/parser.cpp
Expand Up @@ -215,7 +215,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();
max = i.value();
Expand Down
4 changes: 4 additions & 0 deletions importexport/guitarpro/importgtp-gp6.cpp
Expand Up @@ -2378,7 +2378,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 @@ -876,8 +876,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 @@ -108,9 +108,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) {
Expand Down Expand Up @@ -430,7 +430,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 @@ -446,7 +446,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 @@ -1124,7 +1124,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);
Expand Down
4 changes: 4 additions & 0 deletions importexport/musedata/musedata.cpp
Expand Up @@ -47,7 +47,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
6 changes: 5 additions & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -932,7 +932,7 @@ static void handleTupletStop(Tuplet*& tuplet, const int normalNotes)
//---------------------------------------------------------

static void setElementPropertyFlags(ScoreElement* element, const Pid propertyId,
const QString value1, const QString value2 = QString::null)
const QString value1, const QString value2 = QString())
{
if (value1.isEmpty()) { // Set as an implicit value
element->setPropertyFlags(propertyId, PropertyFlags::STYLED);
Expand Down Expand Up @@ -3389,7 +3389,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 @@ -183,8 +183,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 @@ -3589,7 +3589,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 @@ -9487,7 +9491,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 @@ -9881,7 +9889,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
4 changes: 4 additions & 0 deletions inspectors/utils/doubleinputvalidator.cpp
Expand Up @@ -22,7 +22,11 @@ void DoubleInputValidator::fixup(QString& string) const
if (string.endsWith("."))
string.append(zeros(m_decimal));

#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList strList = string.split(".", Qt::SkipEmptyParts);
#else
QStringList strList = string.split(".", QString::SkipEmptyParts);
#endif

QString intPart = strList.at(0);
QString floatPart = strList.at(1);
Expand Down
4 changes: 4 additions & 0 deletions inspectors/view/ui/inspectorBase.cpp
Expand Up @@ -124,7 +124,11 @@ QVariant InspectorBase::getValue(const InspectorItem& ii) const
v = QVariant::fromValue<Direction>(Direction(v.toInt()));
break;
case P_TYPE::INT_LIST: {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = v.toString().split(",", Qt::SkipEmptyParts);
#else
QStringList sl = v.toString().split(",", QString::SkipEmptyParts);
#endif
QList<int> il;
for (const QString& l : sl) {
int i = l.simplified().toInt();
Expand Down
32 changes: 0 additions & 32 deletions inspectors/view/ui/inspector_ambitus.ui
Expand Up @@ -878,22 +878,6 @@
</tabstops>
<resources/>
<connections>
<connection>
<sender>hasLine</sender>
<signal>toggled(bool)</signal>
<receiver>label_10</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>44</x>
<y>137</y>
</hint>
<hint type="destinationlabel">
<x>50</x>
<y>149</y>
</hint>
</hints>
</connection>
<connection>
<sender>hasLine</sender>
<signal>toggled(bool)</signal>
Expand All @@ -910,21 +894,5 @@
</hint>
</hints>
</connection>
<connection>
<sender>hasLine</sender>
<signal>toggled(bool)</signal>
<receiver>resetLineWidth</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>163</x>
<y>134</y>
</hint>
<hint type="destinationlabel">
<x>242</x>
<y>152</y>
</hint>
</hints>
</connection>
</connections>
</ui>
32 changes: 0 additions & 32 deletions inspectors/view/ui/inspector_fermata.ui
Expand Up @@ -208,22 +208,6 @@
</tabstops>
<resources/>
<connections>
<connection>
<sender>playArticulation</sender>
<signal>toggled(bool)</signal>
<receiver>label_2</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>40</x>
<y>91</y>
</hint>
<hint type="destinationlabel">
<x>44</x>
<y>108</y>
</hint>
</hints>
</connection>
<connection>
<sender>playArticulation</sender>
<signal>toggled(bool)</signal>
Expand All @@ -240,21 +224,5 @@
</hint>
</hints>
</connection>
<connection>
<sender>playArticulation</sender>
<signal>toggled(bool)</signal>
<receiver>resetTimeStretch</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>157</x>
<y>89</y>
</hint>
<hint type="destinationlabel">
<x>178</x>
<y>106</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 6a71eb2

Please sign in to comment.