Skip to content

Commit

Permalink
Prevent crash when originalSize is null
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Jul 19, 2024
1 parent 03c574c commit 28f5c78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gui/iconutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ QImage createSvgImageWithCustomColor(const QString &fileName,
return {};
}

const auto sizeToUse = requestedSize.isValid() || originalSize == nullptr ? 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;
Expand All @@ -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()) {
Expand Down

0 comments on commit 28f5c78

Please sign in to comment.