QAccessibleCache: Replace Q_GLOBAL_STATIC by instance pointer
QAccessibleCache is a QObject which emits signals at destruction time. This can lead to crashes in situations where the library is unloaded after QApplication has been deleted, for example in PySide2. Change it to a pointer instance variable that is cleaned up by a post routine. Task-number: PYSIDE-452 Change-Id: If0d673c7dfe33c8d2d7298bc081824f9d6d7efdc Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
parent
944110089d
commit
fed6c35461
@ -49,11 +49,21 @@ QT_BEGIN_NAMESPACE
|
||||
\brief Maintains a cache of accessible interfaces.
|
||||
*/
|
||||
|
||||
Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache)
|
||||
static QAccessibleCache *accessibleCache = nullptr;
|
||||
|
||||
static void cleanupAccessibleCache()
|
||||
{
|
||||
delete accessibleCache;
|
||||
accessibleCache = Q_NULLPTR;
|
||||
}
|
||||
|
||||
QAccessibleCache *QAccessibleCache::instance()
|
||||
{
|
||||
return qAccessibleCache;
|
||||
if (!accessibleCache) {
|
||||
accessibleCache = new QAccessibleCache;
|
||||
qAddPostRoutine(cleanupAccessibleCache);
|
||||
}
|
||||
return accessibleCache;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user