Minimal fix for network-manager problem on plugin unload.

This fixes the problem as long as we have C++ 11's semantics for
in-function statics.  The Q_GLOBAL_STATIC_WITH_ARGS() is a non-trivial
wrapper whose destructor gets unloaded with the plugin, leading to a
crash-on-exit if the global it wraps outlives the plugin.  The plain
(in-function) static manages to avoid this by avoiding the wrapper.
As the static was only needed in one place, this proves a sufficient
solution to the plugin-unload problem *in this case*.

Task-number: QTBUG-45891
Change-Id: I599fbee0b55ece4dceb4bf7202db374b507f5388
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2015-10-16 16:05:42 +02:00
parent 5fecbfb2c8
commit 6be65702f8

View File

@ -51,11 +51,6 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")))
#endif
QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
: QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
{
@ -382,7 +377,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
bool envOK = false;
const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK);
QBearerEngine *generic = 0;
QFactoryLoader *l = loader();
static QFactoryLoader loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer"));
QFactoryLoader *l = &loader;
const PluginKeyMap keyMap = l->keyMap();
const PluginKeyMapConstIterator cend = keyMap.constEnd();
QStringList addedEngines;