[Development] Removing the global static QObject from QPixmapCache

2021-05-29 Thread Sze Howe Koh
== Issue ==
There is a rule that "QCoreApplication should be the first QObject
created and last destroyed" [1]. However, there exists a violation to
this rule in Qt's internals -- QPixmapCache uses an internal global
static QObject (a QPMCache, to be precise) [2].

If initialized, the QPMCache outlives the QGuiApplication and gets
destroyed when the program/library is unloaded. This violates the rule
above.

This also causes problems when the QGuiApplication is created in a
std::thread instead of in main() (e.g. when a non-Qt application loads
a Qt-based plugin to display a GUI) -- The QPMCache destructor is run
by the wrong thread, which produces a warning, " QObject::~QObject:
Timers cannot be stopped from another thread ". There are also reports
that this can cause crashes [3][4].


== Proposal ==
QPMCache does not need the thread-safe initialization offered by
QGlobalStatic, since it can only be used from the Qt GUI thread. It
should also not outlive QGuiApplication.

So, I propose replacing QGlobalStatic with
QPointer as a simple self-cleaning singleton, and replacing
access to the global variable with QPMCache::instance():

QPointer pm_cache;

QPMCache *QPMCache::instance() {
if (!pm_cache && qGuiApp && !qGuiApp->closingDown()) {
Q_ASSERT_X(QThread::currentThread() == qGuiApp->thread(),
"QPixmapCache initialization", "QPixmap can only be accessed from the
GUI thread");

pm_cache = new QPMCache;
connect(qGuiApp, ::aboutToQuit, [] {
QPixmapCache::clear();
pm_cache->deleteLater();
});
}
return pm_cache;
}


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

Thoughts?


Regards,
Sze-Howe

[1] 
https://bugreports.qt.io/browse/QTBUG-71545?focusedCommentId=430042#comment-430042
[2] 
https://code.woboq.org/qt5/qtbase/src/gui/image/qpixmapcache.cpp.html#pm_cache
[3] https://forum.qt.io/topic/126128/qapplication-in-std-thread
[4] https://forum.qt.io/topic/126168/global-static-qpixmapcache-in-qt-internals
[5] https://bugreports.qt.io/browse/QTBUG-21807
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Moving IRC from Freenode to Libera.Chat, voting thread

2021-05-29 Thread Elvis Stansvik
Thanks for taking care of this Peppe.

Elvis

Den lör 29 maj 2021 kl 18:24 skrev Giuseppe D'Angelo via Development
:
>
> Hi,
>
> On 28/05/2021 00:06, Giuseppe D'Angelo via Development wrote:
> > On 22/05/2021 03:06, Giuseppe D'Angelo via Development wrote:
> >> == DEADLINE FOR VOTING ==
> >>
> >> 23.59 CEST of Thursday 27 May 2021.
> > We have unanimous consent.
>
> == Update ==
>
> This is now in effect. We have control over the #qt-* channels on
> Libera. Our official presence is there now.
>
> Most of the channels in the #qt-* namespace have been re-registered,
> incl. #qtwebkit, #qtwebengine, #qbs. Please contact me (in private
> email) if you want to manage some of those.
>
> The online communities wiki page has been updated.
>
>
> == What does this mean for me ==
>
> Simply make your IRC client to irc.libera.chat/6697 (TLS), join the same
> channels. If you prefer Matrix, a bridge has been set up.
>
> The first time you connect, consider re-registering your nick, and
> configure your client to authenticate there. That's it.
>
>
> == Next steps ==
>
> 1) I'd like some volunteers as backup community contacts, so I'm not the
> SPOF of the whole operation. Please write to me (in private email) if
> you're interested.
>
> 2) We'll (slowly) rebuild the ACLs. Approvers and other channel
> "owners", if you wish, please write to me (in private email!) telling me
> your nick registration on Libera, so I can give you powers on #qt-labs.
> Similarly please tell me if you want a hostname cloak.
>
> 3) I'm not changing topics nor auto-join messages in the Freenode
> channels, for a few more days at least, to give people an opportunity
> to move quietly. It seems that the sole mention of Libera.Chat is
> sufficient for the Freenode staff to forcibly take the channels over,
> and I would like to avoid "drama" if possible. Still, this is an active
> threat, so the sooner people move, the better.
>
> https://i.imgur.com/laFn6MM.png (#qt-fr being seized)
>
> https://www.devever.net/~hl/freenode_abuse2
>
>
> Thanks,
> --
> Giuseppe D'Angelo | giuseppe.dang...@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
>
> ___
> Development mailing list
> Development@qt-project.org
> https://lists.qt-project.org/listinfo/development
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Moving IRC from Freenode to Libera.Chat, voting thread

2021-05-29 Thread Giuseppe D'Angelo via Development

Hi,

On 28/05/2021 00:06, Giuseppe D'Angelo via Development wrote:

On 22/05/2021 03:06, Giuseppe D'Angelo via Development wrote:

== DEADLINE FOR VOTING ==

23.59 CEST of Thursday 27 May 2021.

We have unanimous consent.


== Update ==

This is now in effect. We have control over the #qt-* channels on 
Libera. Our official presence is there now.


Most of the channels in the #qt-* namespace have been re-registered, 
incl. #qtwebkit, #qtwebengine, #qbs. Please contact me (in private 
email) if you want to manage some of those.


The online communities wiki page has been updated.


== What does this mean for me ==

Simply make your IRC client to irc.libera.chat/6697 (TLS), join the same 
channels. If you prefer Matrix, a bridge has been set up.


The first time you connect, consider re-registering your nick, and 
configure your client to authenticate there. That's it.



== Next steps ==

1) I'd like some volunteers as backup community contacts, so I'm not the 
SPOF of the whole operation. Please write to me (in private email) if 
you're interested.


2) We'll (slowly) rebuild the ACLs. Approvers and other channel 
"owners", if you wish, please write to me (in private email!) telling me 
your nick registration on Libera, so I can give you powers on #qt-labs. 
Similarly please tell me if you want a hostname cloak.


3) I'm not changing topics nor auto-join messages in the Freenode 
channels, for a few more days at least, to give people an opportunity 
to move quietly. It seems that the sole mention of Libera.Chat is 
sufficient for the Freenode staff to forcibly take the channels over, 
and I would like to avoid "drama" if possible. Still, this is an active 
threat, so the sooner people move, the better.


https://i.imgur.com/laFn6MM.png (#qt-fr being seized)

https://www.devever.net/~hl/freenode_abuse2


Thanks,
--
Giuseppe D'Angelo | giuseppe.dang...@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



smime.p7s
Description: S/MIME Cryptographic Signature
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development