From 60d28c8c7c1e3d077db88b80a04842f984d02182 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 12 Dec 2024 13:50:11 +0100 Subject: [PATCH] Android: Fix some warnings Use a static logging category where possible, and check the return value of QFile::open. Change-Id: Ieda9f7874d1b88d9bfeb593243eb867d0c274e9f Reviewed-by: Volker Hilsheimer Reviewed-by: Marc Mutz (cherry picked from commit e0ef713a2c6a74fe574481e98f0a582819418ed0) Reviewed-by: Qt Cherry-pick Bot --- .../platforms/android/qandroidplatformiconengine.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/android/qandroidplatformiconengine.cpp b/src/plugins/platforms/android/qandroidplatformiconengine.cpp index bab6eeb9d4a..f7b15aeca8d 100644 --- a/src/plugins/platforms/android/qandroidplatformiconengine.cpp +++ b/src/plugins/platforms/android/qandroidplatformiconengine.cpp @@ -21,7 +21,7 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; -Q_LOGGING_CATEGORY(lcIconEngineFontDownload, "qt.qpa.iconengine.fontdownload") +Q_STATIC_LOGGING_CATEGORY(lcIconEngineFontDownload, "qt.qpa.iconengine.fontdownload") // the primary types to work with the FontRequest API Q_DECLARE_JNI_CLASS(FontRequest, "androidx/core/provider/FontRequest") @@ -203,7 +203,13 @@ static QString fetchFont(const QString &query) int fd = fileDescriptor.callMethod("detachFd"); QFile file; - file.open(fd, QFile::OpenModeFlag::ReadOnly, QFile::FileHandleFlag::AutoCloseHandle); + if (!file.open(fd, QFile::OpenModeFlag::ReadOnly, + QFile::FileHandleFlag::AutoCloseHandle)) { + qCWarning(lcIconEngineFontDownload, "Font file '%ls' cannot be opened: %ls", + qUtf16Printable(fontUri.toString()), + qUtf16Printable(file.errorString())); + continue; + } const QByteArray fontData = file.readAll(); qCDebug(lcIconEngineFontDownload) << "Font file read:" << fontData.size() << "bytes"; int fontId = QFontDatabase::addApplicationFontFromData(fontData);