[Development] QQmlAbstractUrlInterceptor (Import control from Qt CS)

Alan Alpert 416365416c at gmail.com
Thu Jul 25 17:51:36 CEST 2013


On Thu, Jul 25, 2013 at 2:25 AM, Alberto Mardegan
<mardy at users.sourceforge.net> wrote:
> On 07/24/2013 06:47 PM, Alan Alpert wrote:
>> Discussed at Qt CS as the mechanism for both file selectors and
>> providing import control was a new QQmlAbstractUrlInterceptor class.
>> You can provide a subclass of this to the QML engine to intercept all
>> local file and QRC access, when combined with a custom
>> QNetworkAccessManager the application has full control over all file
>> and network access attempted by the engine.
>
> Would it make sense to have it in QCoreApplication instead of just
> QQmlEngine?

No, The point of QQmlAbstractUrlInterceptor is primarily to intercept
URLs on the 'fast track' in the QML engine, because we keep a
distinction between 'local files that can be accessed synchronously'
and 'non-local files which cannot'. Without this internal distinction,
QNetworkAccessManager can be used to intercept and redirect
everything.

It used to be that the QQmlEngine docs said to set a custom
QNetworkAccessmanager for intercepting file access, but this had three
important drawbacks
1) You have to use a custom URL everywhere
2) You take the slow path when you don't actually need to
3) You can't affect local module imports, like QtQuick.

I don't think that QCoreApplication does very much direct file access
internally, unlike the QQmlEngine. I don't see this generalizing to
"all file access within the application", because it only applies to
file accesses being taken by mechanisms outside your control (if you
want to intercept a URL for QFile()... you just give it a different
path). The only other such big semi-opaque file accessor I can think
of would be webkit, but it's probably happy with just the custom QNAM.

--
Alan Alpert



More information about the Development mailing list