QIcon::fromTheme(xxx, someFallback)
David Faure
faure at kde.org
Thu Sep 10 07:16:11 UTC 2015
On Wednesday 09 September 2015 10:24:23 Olivier Goffart wrote:
>
> I tried to optimize it by 'caching' the isNull value in QIconPrivate.
>
> But then the test failed:
> http://code.woboq.org/qt5/qtbase/tests/auto/gui/image/qicon/tst_qicon.cpp.html#633
> In that test, the "address-book-new" was looked before and cached, and then we
> expect that looking it up again after changing the theme name changes.
> So cahcing the value of isNull would make the test fail, because it would be
> cached as not null. Yes, the behaviour is that when changing the themeName,
> existing QIcon will be re-looked-up next time we try to render them.
One solution would be a "change counter" in the icon engine, incremented
when changing themes. In QIcon, comparing a local number with that change counter,
and skipping the cache if they don't match. But of course this means one more int
per icon, so I don't know if it's a good idea.
But yeah your isNull implementation looks fast enough; I was afraid it would be a call
to availableSizes() like fromTheme was doing.
--
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
More information about the Kde-frameworks-devel
mailing list