summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-05 18:10:44 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-05 18:10:44 (GMT)
commit638aa0a813f2e79d91f011a2c59558012f804cd7 (patch)
treef0a0ba023197fde5a9fce61b056b8a0babebf8c0 /tools
parentd4bed7dac60406fb98cc6c2b67689db153a56abf (diff)
parentdcee6994616e8352f590a62509a1b64494452fff (diff)
downloadQt-638aa0a813f2e79d91f011a2c59558012f804cd7.zip
Qt-638aa0a813f2e79d91f011a2c59558012f804cd7.tar.gz
Qt-638aa0a813f2e79d91f011a2c59558012f804cd7.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: Make declarative pixmap cache easier to use Prepare for QTest persistent store for visual tests. Loosen font-sensitive test. Set correct license header. Work around QTBUG-11929 <br/> shouldn't trigger a new format range in QDeclarativeStyledText. Add styled text layout benchmark. Optimize QDeclarativeStyledText. 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.cpp2
-rw-r--r--tools/qml/qmlruntime.cpp104
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 ();
}