PDA

View Full Version : QNetworkAccessManager and QNetworkDiskCache ownership



zacao
14th May 2010, 16:25
Hi everyone,

I'm creating an application that uses several QNetworkAccessManagers instances. I would like to share the same files from the default cache directory between these QNetworkAcessManagers, but, Qt documentation says that: "Currently you can not share the same cache files with more then one disk cache.".

So, my idea is to share a single instance of QNetworkDiskCache between all QNetworkAccessManager instances, but, it was not possible because QNetworkAccessManager takes the ownership of QNetworkDiskCache.

My questions are:

1) Is there any way to disable the ownership ?
2) If not, anyone has suggestions in how to solve my problem?

Thanks in advance!

squidge
14th May 2010, 17:48
I'd have to ask why you'd want more than one QNetworkAccessManager. It's not really processor intensive, so would not benefit from being multi-threaded, and you can make lots of requests at once.

Alternatively, you could subclass QAbstractNetworkCache and set the cache to that.

zacao
14th May 2010, 19:41
I'm not sure if what I'm doing is a good practice, but, in fact, I have a couple of instances of QWebPage each one with a QNetworkAccessManager respectivelly. Each QWebPage is accessing differents servers at the same time. Is there another way for doing this? For example, can I use the same QNetworkAccessManager for all QWebPage instances?

Thanks again!

squidge
14th May 2010, 23:00
I would assume so, considering the asynchronous nature of it.