Skip to content

Commit

Permalink
refactor: using qChecksum(QByteArrayView) for Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
CoelacanthusHex committed Nov 3, 2020
1 parent c145fe2 commit f3d0bc9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion makespec/BUILDVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
59
60
8 changes: 8 additions & 0 deletions src/lemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,11 @@ void LemonLime::saveContest(const QString &fileName)
curContest->writeToStream(_out);
data = qCompress(data);
QDataStream out(&file);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
out << unsigned(MagicNumber) << qChecksum(QByteArrayView(data)) << data.length();
#else
out << unsigned(MagicNumber) << qChecksum(data.data(), static_cast<uint>(data.length())) << data.length();
#endif
out.writeRawData(data.data(), data.length());
QApplication::restoreOverrideCursor();
ui->statusBar->showMessage(tr("Saved"), 1000);
Expand Down Expand Up @@ -727,7 +731,11 @@ void LemonLime::loadContest(const QString &filePath)
char *raw = new char[len];
_in.readRawData(raw, len);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (qChecksum(QByteArrayView(raw, static_cast<uint>(len))) != checksum)
#else
if (qChecksum(raw, static_cast<uint>(len)) != checksum)
#endif
{
QMessageBox::warning(this, tr("Error"), tr("File %1 is broken").arg(QFileInfo(filePath).fileName()),
QMessageBox::Close);
Expand Down
8 changes: 8 additions & 0 deletions src/opencontestwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ void OpenContestWidget::refreshContestList()
char *raw = new char[len];
_in.readRawData(raw, len);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (qChecksum(QByteArrayView(raw, static_cast<uint>(len))) != checksum)
#else
if (qChecksum(raw, static_cast<uint>(len)) != checksum)
#endif
{
delete[] raw;
recentContest.removeAt(i);
Expand Down Expand Up @@ -118,7 +122,11 @@ void OpenContestWidget::addContest()
char *raw = new char[len];
in.readRawData(raw, len);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (qChecksum(QByteArrayView(raw, static_cast<uint>(len))) != checksum)
#else
if (qChecksum(raw, static_cast<uint>(len)) != checksum)
#endif
{
QMessageBox::warning(this, tr("Error"), tr("Broken contest data file"), QMessageBox::Close);
delete[] raw;
Expand Down

0 comments on commit f3d0bc9

Please sign in to comment.