[Development] Removing the global static QObject from QPixmapCache

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sun May 30 13:04:03 CEST 2021


Hi,

On 30/05/2021 07:28, Sze Howe Koh wrote:
> 
> So, I propose replacing QGlobalStatic<QPMCache> with
> QPointer<QPMCache> as a simple self-cleaning singleton, and replacing
> access to the global variable with QPMCache::instance():

I'd tend to agree with idea, but not with the specific solution. You may 
want

1) to keep the cache alive across multiple QGA::exec() invocations,
2) to destroy it only when QGA gets destroyed,
3) to recreate it if QGA itself gets recreated.

A very simple solution is to make the cache a member of QGA(P), create 
it lazily if needed (like Q_G_S does; but I've got the funny feeling 
that the pixmap cache is used in 100% Qt apps, so maybe that's not even 
needed), and kill it in ~QGA.

> I believe this approach should also take care of the ancient QTBUG-21807 [5]

This has already been fixed, actually, in 5.0:

> https://github.com/qt/qtbase/commit/6615dc1370300188f2979fb2c6b8eaa6049d5824


Thanks,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20210530/96b53883/attachment.bin>


More information about the Development mailing list