Android: check manifest existence before reading content

It's looks to me that the manifest file might be opened
from various places to get the package name or activity
name, that can happen before the manifest file is even
written or copied from templates. Also, the warning
message added to the "General Messages" is not super
informative about what task is reading the file, so in
many cases the those general messages section can end up
filled with such messages. Instead make it leave it to the
calling task to fail with its error when the returned content
is not valid.

Change-Id: I4e326e15e628e3abfe7b63ffef02d84cf478e377
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Assam Boudjelthia
2024-10-20 15:08:17 +03:00
parent ac8ce27bbf
commit 1b1e4e4d43

View File

@@ -54,6 +54,12 @@ static Q_LOGGING_CATEGORY(androidManagerLog, "qtc.android.androidManager", QtWar
static std::optional<QDomElement> documentElement(const FilePath &fileName)
{
if (!fileName.exists()) {
qCDebug(androidManagerLog, "Manifest file %s doesn't exist.",
fileName.toUserOutput().toUtf8().data());
return {};
}
const expected_str<QByteArray> result = fileName.fileContents();
if (!result) {
MessageManager::writeDisrupting(Tr::tr("Cannot open \"%1\".")