Description
The problem is QNetworkAccessManagerPrivate::findBackend() returns NULL because factoryDataShutdown = true.
factoryDataShutdown is set to true due a bug.
This is the relevant code in qnetworkaccessbackend.cpp:
static bool factoryDataShutdown = false;
class QNetworkAccessBackendFactoryData: public QList<QNetworkAccessBackendFactory *>
{
public:
QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) { }
~QNetworkAccessBackendFactoryData()
QMutex mutex;
};
Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData)
So, when a QNetworkAccessBackendFactoryData object is deleted, it sets factoryDataShutdown to true.
Now here is the code for Q_GLOBAL_STATIC():
#define Q_GLOBAL_STATIC(TYPE, NAME) \
Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
static TYPE *NAME() \
{ \
if (!this_##NAME.pointer && !this_##NAME.destroyed)
\
return this_##NAME.pointer; \
}
So if 2 threads try to create the pointer at the same time, one of them will call "delete x".
In the case of QNetworkAccessBackendFactoryData() this disables the backend factory (on program startup) by setting factoryDataShutdown = true.
Attachments
Issue Links
- relates to
-
QTBUG-20343 QNetworkAccessBackend pointer is NULL when request is done in thread
- Closed