Skip to content

Commit

Permalink
Merge pull request #7584 from nextcloud/bugfix/qt-6-8-compat
Browse files Browse the repository at this point in the history
all: Fix deprecation warnings when building with Qt 6.8.0
  • Loading branch information
mgallien authored Dec 20, 2024
2 parents 2581cdd + f48b988 commit e960b90
Show file tree
Hide file tree
Showing 56 changed files with 171 additions and 182 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ on:
jobs:
clang-tidy:
runs-on: ubuntu-latest
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Prepare compile_commands.json
run: |
cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DQT_MAJOR_VERSION=6 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DOPENSSL_ROOT_DIR=/usr/local/lib64
cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DQT_MAJOR_VERSION=6 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DOPENSSL_ROOT_DIR=/usr/local/lib64
cd build && ninja
- name: Create results directory
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
build:
name: Linux Appimage Package
runs-on: ubuntu-latest
container: ghcr.io/nextcloud/continuous-integration-client-appimage-qt6:client-appimage-6.7.3-1
container: ghcr.io/nextcloud/continuous-integration-client-appimage-qt6:client-appimage-6.8.0-1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Configure, compile and package
run: |
BUILDNR=${GITHUB_RUN_ID} VERSION_SUFFIX=${GITHUB_HEAD_REF} BUILD_UPDATER=ON DESKTOP_CLIENT_ROOT=`pwd` EXECUTABLE_NAME=nextcloud QT_BASE_DIR=/opt/qt6.7.3 OPENSSL_ROOT_DIR=/usr/local/lib64 /bin/bash -c "./admin/linux/build-appimage.sh"
BUILDNR=${GITHUB_RUN_ID} VERSION_SUFFIX=${GITHUB_HEAD_REF} BUILD_UPDATER=ON DESKTOP_CLIENT_ROOT=`pwd` EXECUTABLE_NAME=nextcloud QT_BASE_DIR=/opt/qt6.8.0 OPENSSL_ROOT_DIR=/usr/local/lib64 /bin/bash -c "./admin/linux/build-appimage.sh"
BUILDNR=${GITHUB_RUN_ID} VERSION_SUFFIX=${GITHUB_HEAD_REF} DESKTOP_CLIENT_ROOT=`pwd` /bin/bash -c "./admin/linux/upload-appimage.sh" || echo "Upload failed, however this is an optional step."
4 changes: 2 additions & 2 deletions .github/workflows/linux-clang-compile-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
name: Linux Clang compilation and tests
runs-on: ubuntu-latest
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -15,7 +15,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64
cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64
ninja
- name: Run tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-gcc-compile-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
name: Linux GCC compilation and tests
runs-on: ubuntu-latest
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -15,7 +15,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64
cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64
ninja
- name: Run tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
name: SonarCloud analysis
runs-on: ubuntu-latest
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1
container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1
env:
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
Expand All @@ -25,7 +25,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DQT_MAJOR_VERSION=6 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 -DBUILD_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DQT_MAJOR_VERSION=6 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 -DBUILD_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ninja
- name: Run tests
run: |
Expand Down
5 changes: 2 additions & 3 deletions craftmaster.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ Compile/BuildType = RelWithDebInfo

Compile/UseNinja = True

Paths/downloaddir = ${Variables:Root}\downloads
ShortPath/Enabled = False
ShortPath/EnableJunctions = False

Packager/RepositoryUrl = https://files.kde.org/craft/Qt6
Packager/PackageType = NullsoftInstallerPackager
Packager/CacheVersion = 24.08
Packager/CacheVersion = 24.10

ContinuousIntegration/Enabled = True

Expand All @@ -42,7 +41,7 @@ Packager/CacheDir = ${Variables:Root}\cache
[BlueprintSettings]
nextcloud-client.buildTests = True
binary/mysql.useMariaDB = False
libs/qt6.version = 6.7.2
libs/qt6.version = 6.8.0

[windows-msvc2022_64-cl]
QtSDK/Compiler = msvc2022_64
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/kmessagewidget/kmessagewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void KMessageWidgetPrivate::createLayout()
layout->addWidget(iconLabel);
layout->addWidget(textLabel);

for (QToolButton *button : qAsConst(buttons)) {
for (QToolButton *button : std::as_const(buttons)) {
layout->addWidget(button);
}

Expand Down
4 changes: 2 additions & 2 deletions src/3rdparty/qtsingleapplication/qtlocalpeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ static const char ack[] = "ack";

QString QtLocalPeer::appSessionId(const QString &appId)
{
QByteArray idc = appId.toUtf8();
quint16 idNum = qChecksum(idc.constData(), idc.size());
const auto idc = appId.toUtf8();
const auto idNum = qChecksum(idc);
//### could do: two 16bit checksums over separate halves of id, for a 32bit result - improved uniqeness probability. Every-other-char split would be best.

QString res = QLatin1String("qtsingleapplication-")
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/simplesslerrorhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ bool SimpleSslErrorHandler::handleErrors(QList<QSslError> errors, const QSslConf
}

if (account->trustCertificates()) {
for (const auto &error : qAsConst(errors)) {
for (const auto &error : std::as_const(errors)) {
certs->append(error.certificate());
}
return true;
}

bool allTrusted = true;

for (const auto &error : qAsConst(errors)) {
for (const auto &error : std::as_const(errors)) {
if (!account->approvedCerts().contains(error.certificate())) {
allTrusted = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/checksumcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ bool ChecksumCalculator::addChunk(const QByteArray &chunk, const qint64 size)
} else {
Q_ASSERT(_cryptographicHash);
if (_cryptographicHash) {
_cryptographicHash->addData(chunk.data(), size);
_cryptographicHash->addData(chunk);
return true;
}
}
Expand Down
36 changes: 10 additions & 26 deletions src/common/ownsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,34 +364,24 @@ void SqlQuery::bindValueInternal(int pos, const QVariant &value)
return;
}

switch (value.type()) {
case QVariant::Int:
case QVariant::Bool:
const auto metatype = value.metaType();
if (metatype == QMetaType(QMetaType::Int) || metatype == QMetaType(QMetaType::Bool)) {
res = sqlite3_bind_int(_stmt, pos, value.toInt());
break;
case QVariant::Double:
} else if (metatype == QMetaType(QMetaType::Double)) {
res = sqlite3_bind_double(_stmt, pos, value.toDouble());
break;
case QVariant::UInt:
case QVariant::LongLong:
case QVariant::ULongLong:
} else if (metatype == QMetaType(QMetaType::UInt) || metatype == QMetaType(QMetaType::LongLong) || metatype == QMetaType(QMetaType::ULongLong)) {
res = sqlite3_bind_int64(_stmt, pos, value.toLongLong());
break;
case QVariant::DateTime: {
} else if (metatype == QMetaType(QMetaType::QDateTime)) {
const QDateTime dateTime = value.toDateTime();
const QString str = dateTime.toString(QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"));
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
str.size() * static_cast<int>(sizeof(ushort)), SQLITE_TRANSIENT);
break;
}
case QVariant::Time: {
} else if (metatype == QMetaType(QMetaType::QTime)) {
const QTime time = value.toTime();
const QString str = time.toString(QStringLiteral("hh:mm:ss.zzz"));
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
str.size() * static_cast<int>(sizeof(ushort)), SQLITE_TRANSIENT);
break;
}
case QVariant::String: {
} else if (metatype == QMetaType(QMetaType::QString)) {
if (!value.toString().isNull()) {
// lifetime of string == lifetime of its qvariant
const auto *str = static_cast<const QString *>(value.constData());
Expand All @@ -400,20 +390,14 @@ void SqlQuery::bindValueInternal(int pos, const QVariant &value)
} else {
res = sqlite3_bind_null(_stmt, pos);
}
break;
}
case QVariant::ByteArray: {
} else if (metatype == QMetaType(QMetaType::QByteArray)) {
auto ba = value.toByteArray();
res = sqlite3_bind_text(_stmt, pos, ba.constData(), ba.size(), SQLITE_TRANSIENT);
break;
}
default: {
} else {
QString str = value.toString();
// SQLITE_TRANSIENT makes sure that sqlite buffers the data
res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
(str.size()) * static_cast<int>(sizeof(QChar)), SQLITE_TRANSIENT);
break;
}
}
if (res != SQLITE_OK) {
qCWarning(lcSql) << "ERROR binding SQL value:" << value << "error:" << res;
Expand All @@ -428,7 +412,7 @@ bool SqlQuery::nullValue(int index)

QString SqlQuery::stringValue(int index)
{
return QString::fromUtf16(static_cast<const ushort *>(sqlite3_column_text16(_stmt, index)));
return QString::fromUtf16(static_cast<const char16_t *>(sqlite3_column_text16(_stmt, index)));
}

int SqlQuery::intValue(int index)
Expand Down
4 changes: 2 additions & 2 deletions src/csync/csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ CSYNC_EXCLUDE_TYPE ExcludedFiles::traversalPatternMatch(const QString &path, Ite
QRegularExpressionMatch m;
if (filetype == ItemTypeDirectory
&& _bnameTraversalRegexDir.contains(basePath)) {
m = _bnameTraversalRegexDir[basePath].match(bnameStr);
m = _bnameTraversalRegexDir[basePath].matchView(bnameStr);
} else if (filetype == ItemTypeFile
&& _bnameTraversalRegexFile.contains(basePath)) {
m = _bnameTraversalRegexFile[basePath].match(bnameStr);
m = _bnameTraversalRegexFile[basePath].matchView(bnameStr);
} else {
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions src/csync/vio/csync_vio_local_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ struct csync_vio_handle_t {
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf);

csync_vio_handle_t *csync_vio_local_opendir(const QString &name) {
QScopedPointer<csync_vio_handle_t> handle(new csync_vio_handle_t{});

auto handle = std::make_unique<csync_vio_handle_t>();
auto dirname = QFile::encodeName(name);

handle->dh = _topendir(dirname.constData());
Expand All @@ -62,7 +61,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const QString &name) {
}

handle->path = dirname;
return handle.take();
return handle.release();
}

int csync_vio_local_closedir(csync_vio_handle_t *dhandle) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void AccountManager::save(bool saveCredentials)
{
const auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->setValue(QLatin1String(versionC), maxAccountsVersion);
for (const auto &acc : qAsConst(_accounts)) {
for (const auto &acc : std::as_const(_accounts)) {
settings->beginGroup(acc->account()->id());
saveAccountHelper(acc->account().data(), *settings, saveCredentials);
settings->endGroup();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
QStyleOptionViewItem opt;
opt.initFrom(treeView);
const auto btnRect = treeView->visualRect(indx);
const auto btnSize = treeView->itemDelegate(indx)->sizeHint(opt, indx);
const auto btnSize = treeView->itemDelegateForIndex(indx)->sizeHint(opt, indx);
const auto actual = QStyle::visualRect(opt.direction, btnRect, QRect(btnRect.topLeft(), btnSize));
if (!actual.contains(pos)) {
return;
Expand Down
7 changes: 4 additions & 3 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ bool Application::configVersionMigration()
settings->endGroup();

// Wipe confusing keys from the future, ignore the others
for (const auto &badKey : qAsConst(deleteKeys)) {
for (const auto &badKey : std::as_const(deleteKeys)) {
settings->remove(badKey);
}
}
Expand Down Expand Up @@ -588,7 +588,8 @@ AccountManager::AccountsRestoreResult Application::restoreLegacyAccount()
tr("There was an error while accessing the configuration "
"file at %1. Please make sure the file can be accessed by your system account.")
.arg(ConfigFile().configFile()),
tr("Quit %1").arg(Theme::instance()->appNameGUI()));
QMessageBox::Ok
);
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
}
}
Expand Down Expand Up @@ -1002,7 +1003,7 @@ void Application::setupTranslations()
// have a translation file provided.
qCInfo(lcApplication) << "Using" << lang << "translation";
setProperty("ui_lang", lang);
const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
const QString qtTrPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
const QString qtTrFile = QLatin1String("qt_") + lang;
const QString qtBaseTrFile = QLatin1String("qtbase_") + lang;
if (!qtTranslator->load(qtTrFile, qtTrPath)) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editlocallyjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void EditLocallyJob::lockFile(const QString &etag)

void EditLocallyJob::disconnectFolderSignals()
{
for (const auto &connection : qAsConst(_folderConnections)) {
for (const auto &connection : std::as_const(_folderConnections)) {
disconnect(connection);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editlocallymanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void EditLocallyManager::showError(const QString &message, const QString &inform
void EditLocallyManager::showErrorNotification(const QString &message,
const QString &informativeText)
{
Systray::instance()->showMessage(message, informativeText, Systray::MessageIcon::Critical);
Systray::instance()->showMessage(message, informativeText, Systray::MessageIcon::Critical);
}

void EditLocallyManager::showErrorMessageBox(const QString &message,
Expand Down
4 changes: 2 additions & 2 deletions src/gui/filedetails/sharemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void ShareModel::handlePlaceholderLinkShare()
auto linkSharePresent = false;
auto placeholderLinkSharePresent = false;

for (const auto &share : qAsConst(_shares)) {
for (const auto &share : std::as_const(_shares)) {
const auto shareType = share->getShareType();

if (!linkSharePresent && shareType == Share::TypeLink) {
Expand Down Expand Up @@ -415,7 +415,7 @@ void ShareModel::handleSecureFileDropLinkShare()
auto linkSharePresent = false;
auto secureFileDropLinkSharePresent = false;

for (const auto &share : qAsConst(_shares)) {
for (const auto &share : std::as_const(_shares)) {
const auto shareType = share->getShareType();

if (!linkSharePresent && shareType == Share::TypeLink) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ void Folder::removeLocalE2eFiles()
const auto existingBlacklistSet = QSet<QString>{existingBlacklist.begin(), existingBlacklist.end()};
auto expandedBlacklistSet = QSet<QString>{existingBlacklist.begin(), existingBlacklist.end()};

for (const auto &path : qAsConst(e2eFoldersToBlacklist)) {
for (const auto &path : std::as_const(e2eFoldersToBlacklist)) {
expandedBlacklistSet.insert(path);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/foldercreationdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void FolderCreationDialog::accept()
if (QDir(_destination).mkdir(ui->newFolderNameEdit->text())) {
Q_EMIT folderCreated(fullPath);
} else {
QMessageBox::critical(this, tr("Error"), tr("Could not create a folder! Check your write permissions."));
QMessageBox::critical(this, tr("Error"), tr("Could not create a folder! Check your write permissions."), QMessageBox::Ok);
}

QDialog::accept();
Expand Down
Loading

0 comments on commit e960b90

Please sign in to comment.