diff options
author | Robin Burchell <robin.burchell@viroteck.net> | 2015-02-07 22:44:19 +0100 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2015-02-12 17:21:22 +0000 |
commit | 67d3e3d6d53bb1762ce91912eff0471fa55d4676 (patch) | |
tree | bb16d66937fe3443aab826a3af3ac7ce95d941cd /src/quick/items/qquicktext.cpp | |
parent | d8ee217d41b8c558013c624b15e99f2b8794e8c6 (diff) |
QQuickText: Move baseUrl to ExtraData.
It's only used for external resource loading, which is not the common case.
Note that the case of an unset baseUrl may become a little more pessimised now,
as it has to be looked up from the context which involves a loop to find the
outermost parent context, but again, this is not a common case, so I'd consider
that acceptable.
QQuickTextPrivate now goes from 496 bytes to 488 bytes. ExtraData increases from
72 bytes to 80 on x86_64.
Change-Id: I7e346eeb3b3cefe81912aac2b115e106ec519d1e
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index f64b0cdb19..4cd055594c 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -2070,18 +2070,21 @@ void QQuickText::setElideMode(QQuickText::TextElideMode mode) QUrl QQuickText::baseUrl() const { Q_D(const QQuickText); - if (d->baseUrl.isEmpty()) { + if (!d->extra.isAllocated() || d->extra->baseUrl.isEmpty()) { if (QQmlContext *context = qmlContext(this)) - const_cast<QQuickTextPrivate *>(d)->baseUrl = context->baseUrl(); + return context->baseUrl(); + else + return QUrl(); + } else { + return d->extra->baseUrl; } - return d->baseUrl; } void QQuickText::setBaseUrl(const QUrl &url) { Q_D(QQuickText); if (baseUrl() != url) { - d->baseUrl = url; + d->extra.value().baseUrl = url; if (d->richText) { d->ensureDoc(); |