Skip to content

Commit

Permalink
fix: wrong availableSizes for DIconProxyEngine
Browse files Browse the repository at this point in the history
  We should call proxy's `availableSizes` function.
  `availableSizes` always return empty list for icons, it causes
`QPainter::begin: Paint device returned engine == 0` when painting
to QImage.
  • Loading branch information
18202781743 committed Mar 12, 2024
1 parent 4013869 commit 9d26730
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/util/private/diconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ const
return m_iconEngine ? m_iconEngine->iconName() : QString();
}

QList<QSize> DIconProxyEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const
#endif
{
return m_iconEngine ? m_iconEngine->availableSizes(mode, state) : QIconEngine::availableSizes(mode, state);
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool DIconProxyEngine::isNull()
{
return m_iconEngine ? m_iconEngine->isNull() : QIconEngine::isNull();
}
#endif

QString DIconProxyEngine::proxyKey()
{
ensureEngine();
Expand Down
10 changes: 10 additions & 0 deletions src/util/private/diconproxyengine_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class Q_DECL_HIDDEN DIconProxyEngine : public QIconEngine
#else
QString iconName() const override;
#endif

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) override;
#else
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) const override;
#endif

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool isNull() override;
#endif
inline QString themeName() const { return m_iconThemeName; }

QString proxyKey();
Expand Down

0 comments on commit 9d26730

Please sign in to comment.