From 250f5669533b54c19fc7d7369fee592a6f17bd0f Mon Sep 17 00:00:00 2001 From: ios Date: Thu, 28 Mar 2024 16:18:04 +0200 Subject: [PATCH] Disable error logs when checking resource availability (https://github.com/osmandapp/OsmAnd-Issues/issues/2441) --- .../Core/CoreResourcesFromBundleProvider.h | 5 ++-- .../Core/CoreResourcesFromBundleProvider.mm | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Sources/Core/CoreResourcesFromBundleProvider.h b/Sources/Core/CoreResourcesFromBundleProvider.h index dcf6eec4a9..23706e9e19 100644 --- a/Sources/Core/CoreResourcesFromBundleProvider.h +++ b/Sources/Core/CoreResourcesFromBundleProvider.h @@ -17,9 +17,10 @@ class CoreResourcesFromBundleProvider : public OsmAnd::ICoreResourcesProvider { private: - static NSString* getResourcePath(const QString& name); + static NSString* getResourcePath(const QString& name, const bool logErrors); static NSString* getResourcePath(const QString& name, - const float displayDensityFactor); + const float displayDensityFactor, + const bool logErrors); protected: public: CoreResourcesFromBundleProvider(); diff --git a/Sources/Core/CoreResourcesFromBundleProvider.mm b/Sources/Core/CoreResourcesFromBundleProvider.mm index bab8234528..71893c616e 100644 --- a/Sources/Core/CoreResourcesFromBundleProvider.mm +++ b/Sources/Core/CoreResourcesFromBundleProvider.mm @@ -28,7 +28,7 @@ const float displayDensityFactor, bool* ok /* = nullptr*/) const { - NSString* resourcePath = getResourcePath(name, displayDensityFactor); + NSString* resourcePath = getResourcePath(name, displayDensityFactor, true); if (!resourcePath) { @@ -55,7 +55,7 @@ QByteArray CoreResourcesFromBundleProvider::getResource(const QString& name, bool* ok /* = nullptr*/) const { - NSString* resourcePath = getResourcePath(name); + NSString* resourcePath = getResourcePath(name, true); if (!resourcePath) { @@ -82,19 +82,19 @@ bool CoreResourcesFromBundleProvider::containsResource(const QString& name, const float displayDensityFactor) const { - NSString* resourcePath = getResourcePath(name, displayDensityFactor); + NSString* resourcePath = getResourcePath(name, displayDensityFactor, false); return ([[NSFileManager defaultManager] fileExistsAtPath:resourcePath] == YES); } bool CoreResourcesFromBundleProvider::containsResource(const QString& name) const { - NSString* resourcePath = getResourcePath(name); + NSString* resourcePath = getResourcePath(name, false); return ([[NSFileManager defaultManager] fileExistsAtPath:resourcePath] == YES); } -NSString* CoreResourcesFromBundleProvider::getResourcePath(const QString& name) +NSString* CoreResourcesFromBundleProvider::getResourcePath(const QString& name, const bool logErrors) { NSString* resourceName = nil; NSString* resourceType = nil; @@ -174,7 +174,8 @@ } else { - OALog(@"Unrecognized resource name '%@'", name.toNSString()); + if (logErrors) + OALog(@"Unrecognized resource name '%@'", name.toNSString()); return nil; } @@ -183,7 +184,8 @@ inDirectory:resourceDir]; if (!resourcePath) { - OALog(@"Failed to locate '%@', but it have to be present", name.toNSString()); + if (logErrors) + OALog(@"Failed to locate '%@', but it have to be present", name.toNSString()); return nil; } @@ -191,7 +193,8 @@ } NSString* CoreResourcesFromBundleProvider::getResourcePath(const QString& name, - const float displayDensityFactor) + const float displayDensityFactor, + const bool logErrors) { NSString* resourceName = nil; NSString* resourceType = nil; @@ -259,7 +262,8 @@ } else { - OALog(@"Unrecognized resource name '%@'", name.toNSString()); + if (logErrors) + OALog(@"Unrecognized resource name '%@'", name.toNSString()); return nil; } @@ -268,7 +272,8 @@ inDirectory:resourceDir]; if (!resourcePath) { - OALog(@"Failed to locate '%@', but it have to be present", name.toNSString()); + if (logErrors) + OALog(@"Failed to locate '%@', but it have to be present", name.toNSString()); return nil; }