Changeset 117094 in webkit
- Timestamp:
- May 15, 2012 11:00:13 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117091 r117094 1 2012-05-15 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2 3 [Qt] WebKit with Qt5 hangs on Mac 4 https://bugs.webkit.org/show_bug.cgi?id=79785 5 6 Reviewed by Tor Arne Vestbø. 7 8 Delay the initialization of our QNetworkConfigurationManager used in 9 NetworkStateNotifierPrivate. On Mac it was causing a race condition because it 10 spawns a thread that triggers a static initializer in Qt, while in the main 11 thread NetworkStateNotifier is being static initialized. On Mac the lock for 12 static initializers is shared between all of them, causing a deadlock. 13 14 The issue was also reported in http://openradar.appspot.com/11217150. 15 16 * platform/network/qt/NetworkStateNotifierPrivate.h: 17 (NetworkStateNotifierPrivate): 18 (WebCore::NetworkStateNotifierPrivate::effectivelyOnline): 19 * platform/network/qt/NetworkStateNotifierQt.cpp: 20 (WebCore::NetworkStateNotifierPrivate::NetworkStateNotifierPrivate): 21 (WebCore::NetworkStateNotifierPrivate::setNetworkAccessAllowed): 22 (WebCore::NetworkStateNotifierPrivate::setOnlineState): 23 (WebCore::NetworkStateNotifierPrivate::initialize): 24 (WebCore): 25 (WebCore::NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate): 26 (WebCore::NetworkStateNotifier::updateState): 27 (WebCore::NetworkStateNotifier::NetworkStateNotifier): 28 (WebCore::NetworkStateNotifier::setNetworkAccessAllowed): 29 1 30 2012-05-15 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 31 -
trunk/Source/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h
r95901 r117094 22 22 23 23 #include <QObject> 24 #include <wtf/OwnPtr.h> 24 25 25 26 QT_BEGIN_NAMESPACE … … 36 37 NetworkStateNotifierPrivate(NetworkStateNotifier* notifier); 37 38 ~NetworkStateNotifierPrivate(); 39 40 void setNetworkAccessAllowed(bool); 41 bool effectivelyOnline() const { return m_online && m_networkAccessAllowed; } 42 38 43 public slots: 39 void onlineStateChanged(bool); 40 void networkAccessPermissionChanged(bool); 44 void setOnlineState(bool); 45 46 private slots: 47 void initialize(); 41 48 42 49 public: 43 QNetworkConfigurationManager*m_configurationManager;50 OwnPtr<QNetworkConfigurationManager> m_configurationManager; 44 51 bool m_online; 45 52 bool m_networkAccessAllowed; -
trunk/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp
r95901 r117094 24 24 25 25 #include "NetworkStateNotifierPrivate.h" 26 #include "qnetworkconfigmanager.h" 26 #include <QNetworkConfigurationManager> 27 #include <QTimer> 28 #include <wtf/PassOwnPtr.h> 27 29 28 30 namespace WebCore { 29 31 30 32 NetworkStateNotifierPrivate::NetworkStateNotifierPrivate(NetworkStateNotifier* notifier) 31 : m_configurationManager(new QNetworkConfigurationManager()) 32 , m_online(m_configurationManager->isOnline()) 33 : m_online(false) 33 34 , m_networkAccessAllowed(true) 34 35 , m_notifier(notifier) 35 36 { 36 Q_ASSERT(notifier); 37 connect(m_configurationManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool))); 37 ASSERT(notifier); 38 39 // Initialization is delayed because QNetworkConfigurationManager starts a new thread that causes 40 // deadlock on Mac because all the static initializers share the same lock. Both NetworkStateNotifier and Qt internals 41 // triggered in new thread use static initializer. See also: http://openradar.appspot.com/11217150. 42 QTimer::singleShot(0, this, SLOT(initialize())); 38 43 } 39 44 40 void NetworkStateNotifierPrivate::onlineStateChanged(bool isOnline) 45 void NetworkStateNotifierPrivate::setNetworkAccessAllowed(bool isAllowed) 46 { 47 if (isAllowed == m_networkAccessAllowed) 48 return; 49 50 m_networkAccessAllowed = isAllowed; 51 if (m_online) 52 m_notifier->updateState(); 53 } 54 55 void NetworkStateNotifierPrivate::setOnlineState(bool isOnline) 41 56 { 42 57 if (m_online == isOnline) … … 48 63 } 49 64 50 void NetworkStateNotifierPrivate:: networkAccessPermissionChanged(bool isAllowed)65 void NetworkStateNotifierPrivate::initialize() 51 66 { 52 if (isAllowed == m_networkAccessAllowed) 53 return; 54 55 m_networkAccessAllowed = isAllowed; 56 if (m_online) 57 m_notifier->updateState(); 67 m_configurationManager = adoptPtr(new QNetworkConfigurationManager()); 68 setOnlineState(m_configurationManager->isOnline()); 69 connect(m_configurationManager.get(), SIGNAL(onlineStateChanged(bool)), this, SLOT(setOnlineState(bool))); 58 70 } 59 71 60 72 NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate() 61 73 { 62 delete m_configurationManager;63 74 } 64 75 65 76 void NetworkStateNotifier::updateState() 66 77 { 67 if (m_isOnLine == (p->m_online && p->m_networkAccessAllowed))78 if (m_isOnLine == p->effectivelyOnline()) 68 79 return; 69 80 70 m_isOnLine = p-> m_online && p->m_networkAccessAllowed;81 m_isOnLine = p->effectivelyOnline(); 71 82 if (m_networkStateChangedFunction) 72 83 m_networkStateChangedFunction(); … … 78 89 { 79 90 p = new NetworkStateNotifierPrivate(this); 80 m_isOnLine = p-> m_online && p->m_networkAccessAllowed;91 m_isOnLine = p->effectivelyOnline(); 81 92 } 82 93 83 94 void NetworkStateNotifier::setNetworkAccessAllowed(bool isAllowed) 84 95 { 85 p-> networkAccessPermissionChanged(isAllowed);96 p->setNetworkAccessAllowed(isAllowed); 86 97 } 87 98
Note: See TracChangeset
for help on using the changeset viewer.