diff --git a/src/private/dquickimageprovider.cpp b/src/private/dquickimageprovider.cpp index 0cb0b62b..d2283ad7 100644 --- a/src/private/dquickimageprovider.cpp +++ b/src/private/dquickimageprovider.cpp @@ -46,8 +46,6 @@ static QImage requestImageFromQIcon(const QString &id, QSize *size, const QSize } else { icon = DIconTheme::findQIcon(name); } - if (icon.isNull()) - return invalidIcon(size, requestedSize); QIcon::Mode qMode = QIcon::Normal; QIcon::State qState = QIcon::Off; @@ -66,6 +64,11 @@ static QImage requestImageFromQIcon(const QString &id, QSize *size, const QSize devicePixelRatio = 1.0; } + if (icon.isNull()) { + QSize icon_size = requestedSize; + return invalidIcon(size, icon_size /= devicePixelRatio); + } + QSize icon_size = requestedSize; // 初始时可能没有为图标设置期望的大小 if (icon_size.isEmpty()) {