QIcon::availableSizes(): don't return duplicates
QIcon::availableSizes() returned duplicate sizes when there are pixmaps with a different dpi but same size. This is not useful and therefore filter them out. Also rearrange the conditions a little bit to bail out on wrong mode/state early. Task-number: QTBUG-119915 Change-Id: I9d18c78fc2a149a3a9eaaed67c6110979029705b Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit c53b91cc12164d779a69c2526d85e3ab9c2841e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8e6b46fa65
commit
43c220149f
@ -348,15 +348,16 @@ QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::
|
||||
QList<QSize> QPixmapIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
|
||||
{
|
||||
QList<QSize> sizes;
|
||||
for (int i = 0; i < pixmaps.size(); ++i) {
|
||||
QPixmapIconEngineEntry &pe = pixmaps[i];
|
||||
if (pe.size == QSize() && pe.pixmap.isNull()) {
|
||||
for (QPixmapIconEngineEntry &pe : pixmaps) {
|
||||
if (pe.mode != mode || pe.state != state)
|
||||
continue;
|
||||
if (pe.size.isEmpty() && pe.pixmap.isNull()) {
|
||||
pe.pixmap = QPixmap(pe.fileName);
|
||||
pe.size = pe.pixmap.size();
|
||||
}
|
||||
if (pe.mode == mode && pe.state == state && !pe.size.isEmpty())
|
||||
if (!pe.size.isEmpty() && !sizes.contains(pe.size))
|
||||
sizes.push_back(pe.size);
|
||||
}
|
||||
}
|
||||
return sizes;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user