QNetworkInfo: Document threading restriction
Specifically on Windows we use COM, which requires being de-initialized in the same thread as it was initialized. Given that QNetworkInfo is a GLOBAL_STATIC with a qAddPostCondition (iirc APPLICATION_STATIC was not yet implemented at the time) to delete the backend when qApp is destructed, we need to cope with destruction happening on the main thread. If the backend is loaded on a secondary thread, the thread may have shut down, or we may not otherwise be able to rely on emitting Queued emissions to perform the destruction. Conversely we also can't trivially move the construction to the application thread (eg. using BlockingQueued emission during first load) because we may cause a deadlock. This leaves us with just documenting where the first load should happen. Fixes: QTBUG-133644 Pick-to: 6.9 6.8 6.5 Change-Id: I7f52e884151c6c24acc34f1112faabc897d9b0f9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d25e5e2cb7
commit
6ad2918de4
@ -419,6 +419,12 @@ QNetworkInformationBackendFactory::~QNetworkInformationBackendFactory()
|
||||
If you destroy and re-create the QCoreApplication object you must call
|
||||
load() again.
|
||||
|
||||
\note Because the class is a singleton while also relying on
|
||||
QCoreApplication, QNetworkInformation should always first be loaded
|
||||
in the same thread as the QCoreApplication object. This is because the
|
||||
object will also be destroyed in this thread, and various backend-specific
|
||||
components may rely on being destroyed in the same thread as it is created.
|
||||
|
||||
\sa QNetworkInformation::Feature
|
||||
*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user