summaryrefslogtreecommitdiffstats
path: root/tools/qml/qmlruntime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qml/qmlruntime.cpp')
-rw-r--r--tools/qml/qmlruntime.cpp58
1 files changed, 34 insertions, 24 deletions
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index c7acf2c..6660947 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -351,30 +351,10 @@ private:
class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
{
public:
- NetworkAccessManagerFactory() : cookieJar(0), cacheSize(0) {}
- ~NetworkAccessManagerFactory() {
- delete cookieJar;
- }
+ NetworkAccessManagerFactory() : cacheSize(0) {}
+ ~NetworkAccessManagerFactory() {}
- QNetworkAccessManager *create(QObject *parent) {
- QMutexLocker lock(&mutex);
- QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
- if (!cookieJar)
- cookieJar = new PersistentCookieJar(0);
- manager->setCookieJar(cookieJar);
- cookieJar->setParent(0);
- setupProxy(manager);
- if (cacheSize > 0) {
- QNetworkDiskCache *cache = new QNetworkDiskCache;
- cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache"));
- cache->setMaximumCacheSize(cacheSize);
- manager->setCache(cache);
- } else {
- manager->setCache(0);
- }
- qDebug() << "created new network access manager for" << parent;
- return manager;
- }
+ QNetworkAccessManager *create(QObject *parent);
void setupProxy(QNetworkAccessManager *nam)
{
@@ -419,11 +399,41 @@ public:
}
}
- PersistentCookieJar *cookieJar;
+ static PersistentCookieJar *cookieJar;
QMutex mutex;
int cacheSize;
};
+PersistentCookieJar *NetworkAccessManagerFactory::cookieJar = 0;
+
+static void cleanup_cookieJar()
+{
+ delete NetworkAccessManagerFactory::cookieJar;
+ NetworkAccessManagerFactory::cookieJar = 0;
+}
+
+QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
+{
+ QMutexLocker lock(&mutex);
+ QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
+ if (!cookieJar) {
+ qAddPostRoutine(cleanup_cookieJar);
+ cookieJar = new PersistentCookieJar(0);
+ }
+ manager->setCookieJar(cookieJar);
+ cookieJar->setParent(0);
+ setupProxy(manager);
+ if (cacheSize > 0) {
+ QNetworkDiskCache *cache = new QNetworkDiskCache;
+ cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache"));
+ cache->setMaximumCacheSize(cacheSize);
+ manager->setCache(cache);
+ } else {
+ manager->setCache(0);
+ }
+ qDebug() << "created new network access manager for" << parent;
+ return manager;
+}
QString QDeclarativeViewer::getVideoFileName()
{