From b5ca7e6057bcad7334c5d99664cace77dd893fa0 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Sun, 10 Nov 2013 16:52:42 -0500 Subject: [PATCH] Fix OS X keychain bug in Qt 5 * Performing basic auth would pop up a keychain dialog * Pressing "Accept" resulted in an infinite loop --- src/NetworkAccessManager.cpp | 10 ++++++++++ src/NetworkAccessManager.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/NetworkAccessManager.cpp b/src/NetworkAccessManager.cpp index 9421af7..d06a33f 100644 --- a/src/NetworkAccessManager.cpp +++ b/src/NetworkAccessManager.cpp @@ -8,6 +8,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent):QNetworkAccessManager(parent) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*))); connect(this, SIGNAL(finished(QNetworkReply *)), this, SLOT(finished(QNetworkReply *))); + disableKeyChainLookup(); } QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operation operation, const QNetworkRequest &request, QIODevice * outgoingData = 0) { @@ -93,3 +94,12 @@ bool NetworkAccessManager::isBlacklisted(QUrl url) { return false; }; +/* + * This is a workaround for a Qt 5/OS X bug: + * https://bugreports.qt-project.org/browse/QTBUG-30434 + */ +void NetworkAccessManager::disableKeyChainLookup() { + QNetworkProxy fixedProxy = proxy(); + fixedProxy.setHostName(" "); + setProxy(fixedProxy); +} diff --git a/src/NetworkAccessManager.h b/src/NetworkAccessManager.h index ebaeaf3..06dda54 100644 --- a/src/NetworkAccessManager.h +++ b/src/NetworkAccessManager.h @@ -24,6 +24,8 @@ class NetworkAccessManager : public QNetworkAccessManager { QList m_urlBlacklist; private: + void disableKeyChainLookup(); + QHash m_headers; bool isBlacklisted(QUrl url); QHash m_redirectMappings;