diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-04 11:54:13 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-04 11:54:13 (GMT) |
commit | dac42b0d66eda9a7101847ced61c118024ef9c6d (patch) | |
tree | c6d1f6a17ad54be4cd0092bded2ca513cd5f2b78 /tools | |
parent | 76aad35bd9f699c966295738095d245a5e7a6457 (diff) | |
parent | b68a5d2cd6b08504b354b09465ab05593120fee8 (diff) | |
download | Qt-dac42b0d66eda9a7101847ced61c118024ef9c6d.zip Qt-dac42b0d66eda9a7101847ced61c118024ef9c6d.tar.gz Qt-dac42b0d66eda9a7101847ced61c118024ef9c6d.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Don't write to the logger widget while the application is closing down.
Fix exponential behavior of QTextCursor::removeSelectedText
Fix test for N900 (ARM-specific SVG results).
docs - fix doc links, minor improvements
Fix TextEdit bitmap tests testing the wrong element
Make autotests work with qreal == float (in addition to double).
Fix TextInput text getting improperly clipped
fix doc links
Fix docs to link to the new QML Viewer page instead of the Runtime page
qmlviewer: Update the proxy factory when the user changes the proxy.
Don't accept *files* that exist when *directory* is required.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 2 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 104 |
2 files changed, 63 insertions, 43 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 900a464..d0817bc 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -91,7 +91,7 @@ void showWarnings() void myMessageOutput(QtMsgType type, const char *msg) { - if (!logger.isNull()) { + if (!logger.isNull() && !QCoreApplication::closingDown()) { QString strMsg = QString::fromAscii(msg); QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); } else { diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index debc902..03ca798 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -431,65 +431,82 @@ private: mutable QMutex mutex; }; -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +class SystemProxyFactory : public QNetworkProxyFactory { public: - NetworkAccessManagerFactory() : cacheSize(0) {} - ~NetworkAccessManagerFactory() {} - - QNetworkAccessManager *create(QObject *parent); + SystemProxyFactory() : proxyDirty(true), httpProxyInUse(false) { + } - void setupProxy(QNetworkAccessManager *nam) + virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query) { - class SystemProxyFactory : public QNetworkProxyFactory - { - public: - virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query) - { - QString protocolTag = query.protocolTag(); - if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) { - QList<QNetworkProxy> ret; - ret << httpProxy; - return ret; - } + if (proxyDirty) + setupProxy(); + QString protocolTag = query.protocolTag(); + if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) { + QList<QNetworkProxy> ret; + ret << httpProxy; + return ret; + } #ifdef Q_OS_WIN - // systemProxyForQuery can take insanely long on Windows (QTBUG-10106) - return QNetworkProxyFactory::proxyForQuery(query); + // systemProxyForQuery can take insanely long on Windows (QTBUG-10106) + return QNetworkProxyFactory::proxyForQuery(query); #else - return QNetworkProxyFactory::systemProxyForQuery(query); + return QNetworkProxyFactory::systemProxyForQuery(query); #endif - } - void setHttpProxy (QNetworkProxy proxy) - { - httpProxy = proxy; - httpProxyInUse = true; - } - void unsetHttpProxy () - { - httpProxyInUse = false; - } - private: - bool httpProxyInUse; - QNetworkProxy httpProxy; - }; - - SystemProxyFactory *proxyFactory = new SystemProxyFactory; - if (ProxySettings::httpProxyInUse()) - proxyFactory->setHttpProxy(ProxySettings::httpProxy()); - else - proxyFactory->unsetHttpProxy(); - nam->setProxyFactory(proxyFactory); } + void setupProxy() { + // Don't bother locking because we know that the proxy only + // changes in response to the settings dialog and that + // the view will be reloaded. + proxyDirty = false; + httpProxyInUse = ProxySettings::httpProxyInUse(); + if (httpProxyInUse) + httpProxy = ProxySettings::httpProxy(); + } + + void proxyChanged() { + proxyDirty = true; + } + +private: + volatile bool proxyDirty; + bool httpProxyInUse; + QNetworkProxy httpProxy; +}; + +class NetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory +{ + Q_OBJECT +public: + NetworkAccessManagerFactory() : cacheSize(0) {} + ~NetworkAccessManagerFactory() {} + + QNetworkAccessManager *create(QObject *parent); + void setCacheSize(int size) { if (size != cacheSize) { cacheSize = size; } } + void proxyChanged() { + foreach (QNetworkAccessManager *nam, namList) { + static_cast<SystemProxyFactory*>(nam->proxyFactory())->proxyChanged(); + } + } + static PersistentCookieJar *cookieJar; + +private slots: + void managerDestroyed(QObject *obj) { + namList.removeOne(static_cast<QNetworkAccessManager*>(obj)); + } + +private: QMutex mutex; int cacheSize; + QList<QNetworkAccessManager*> namList; }; PersistentCookieJar *NetworkAccessManagerFactory::cookieJar = 0; @@ -510,7 +527,7 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) } manager->setCookieJar(cookieJar); cookieJar->setParent(0); - setupProxy(manager); + manager->setProxyFactory(new SystemProxyFactory); if (cacheSize > 0) { QNetworkDiskCache *cache = new QNetworkDiskCache; cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-viewer-network-cache")); @@ -519,6 +536,8 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) } else { manager->setCache(0); } + connect(manager, SIGNAL(destroyed(QObject*)), this, SLOT(managerDestroyed(QObject*))); + namList.append(manager); qDebug() << "created new network access manager for" << parent; return manager; } @@ -777,6 +796,7 @@ void QDeclarativeViewer::showProxySettings() void QDeclarativeViewer::proxySettingsChanged() { + namFactory->proxyChanged(); reload (); } |