Correctly fall back to originalSize if requestedSize not valid in svg image provider
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 6 Jun 2024 09:43:21 +0000 (17:43 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 6 Jun 2024 16:17:40 +0000 (00:17 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/iconutils.cpp

index c25adbc76d00d7bd98b9f9adf680a567b1b4c1e8..ba9204e039261a2e93416b476c95241c476b7793 100644 (file)
@@ -108,9 +108,11 @@ QImage createSvgImageWithCustomColor(const QString &fileName,
         return {};
     }
 
+    const auto sizeToUse = requestedSize.isValid() ? requestedSize : *originalSize;
+
     // some icons are present in white or black only, so, we need to check both when needed
     const auto iconBaseColors = QStringList{QStringLiteral("black"), QStringLiteral("white")};
-    const auto customColorImage = findImageWithCustomColor(fileName, customColor, iconBaseColors, requestedSize);
+    const auto customColorImage = findImageWithCustomColor(fileName, customColor, iconBaseColors, sizeToUse);
 
     if (!customColorImage.isNull()) {
         return customColorImage;
@@ -125,7 +127,7 @@ QImage createSvgImageWithCustomColor(const QString &fileName,
         return {};
     }
 
-    const auto result = drawSvgWithCustomFillColor(sourceSvg, customColor, originalSize, requestedSize);
+    const auto result = drawSvgWithCustomFillColor(sourceSvg, customColor, originalSize, sizeToUse);
     Q_ASSERT(!result.isNull());
 
     if (result.isNull()) {