diff options
| author | Kaj Grönholm <kaj.gronholm@qt.io> | 2024-06-25 22:04:28 +0300 |
|---|---|---|
| committer | Kaj Grönholm <kaj.gronholm@qt.io> | 2024-07-03 17:36:50 +0300 |
| commit | 8ce32d6d5a57b17ca8bcfabfcf2d10ae6ae8fde6 (patch) | |
| tree | ece05205a7d93b6707fd122265e14bb0b44fb3ab /src/quick/util/qquickpath.cpp | |
| parent | 591bcbb95c14b02e9e989ffc437712f5e856b449 (diff) | |
Support asynchronous path processing in QQuickPath
Each element in QQuickPath calls processPath() when added or changed
and also other property changes call it. This triggers recreation of
the path multiple times, which can be slow. Instead of direcly
processing the path, allow processing it asynchronously only once
per update.
Task-number: QTBUG-126662
Pick-to: 6.8
Change-Id: I7bc8afbf434dc69865e11385493ab3729db6d143
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quick/util/qquickpath.cpp')
| -rw-r--r-- | src/quick/util/qquickpath.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index bd90bf81b6..d8cb6650dc 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -370,6 +370,23 @@ void QQuickPath::processPath() if (!d->componentComplete) return; + if (!d->asynchronous) { + doProcessPath(); + } else if (!d->processPending) { + d->processPending = true; + QMetaObject::invokeMethod(this, &QQuickPath::doProcessPath, Qt::QueuedConnection); + } +} + +void QQuickPath::doProcessPath() +{ + Q_D(QQuickPath); + + d->processPending = false; + + if (!d->componentComplete) + return; + d->_pointCache.clear(); d->prevBez.isValid = false; @@ -580,7 +597,7 @@ void QQuickPath::componentComplete() gatherAttributes(); - processPath(); + doProcessPath(); connectPathElements(); } @@ -749,6 +766,21 @@ bool QQuickPath::simplify() const return d->simplify; } +bool QQuickPath::isAsynchronous() const +{ + Q_D(const QQuickPath); + return d->asynchronous; +} + +void QQuickPath::setAsynchronous(bool a) +{ + Q_D(QQuickPath); + if (d->asynchronous == a) + return; + + d->asynchronous = a; +} + /*! \qmlproperty size QtQuick::Path::scale |
