diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-01-06 17:12:36 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-01-07 17:39:11 +0100 |
commit | 924b2d5d47a33d11999a8edbfe6960e9593038ec (patch) | |
tree | 6ab2777612c0a110b98e27e1b80788e92a35fdb9 /src/qmltest | |
parent | 9ad271350ca53fe07508b37e94e1a6ab36cdf88c (diff) |
Don't crash when pasting text into TextArea
If QQuickTextAreaPrivate::ensureCursorVisible() calls
QQuickFlickable::setContentY() while the Flickable does not yet know the
extents of its new content, it caused a crash when
QQuickScrollBarPrivate::visualArea() called qBound(0, 1, -something).
We need to wait until Flickable knows it can scroll that far. It turns
out ensureCursorVisible() is called several times anyway, so it's OK to
skip the calls that would ask the Flickable to scroll out-of-bounds.
Pick-to: 6.3
Task-number: QTBUG-99582
Change-Id: Ifb374a81591df49d3c571f55cb3076a78a808918
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/quicktestutil.cpp | 13 | ||||
-rw-r--r-- | src/qmltest/quicktestutil_p.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/qmltest/quicktestutil.cpp b/src/qmltest/quicktestutil.cpp index 994c66845b..25863c3842 100644 --- a/src/qmltest/quicktestutil.cpp +++ b/src/qmltest/quicktestutil.cpp @@ -47,6 +47,7 @@ #include <QtQml/private/qjsvalue_p.h> #include <QtGui/qguiapplication.h> +#include <QtGui/qclipboard.h> #include <QtGui/qstylehints.h> #include <QtQml/qqmlengine.h> @@ -62,6 +63,18 @@ int QuickTestUtil::dragThreshold() const return QGuiApplication::styleHints()->startDragDistance(); } +void QuickTestUtil::populateClipboardText(int lineCount) +{ +#if QT_CONFIG(clipboard) + QString fmt(u"%1 bottles of beer on the wall, %1 bottles of beer; " + "take one down, pass it around, %2 bottles of beer on the wall."_qs); + QStringList lines; + for (int i = lineCount; i > 0; --i) + lines << fmt.arg(i).arg(i - 1); + QGuiApplication::clipboard()->setText(lines.join(u'\n')); +#endif +} + QJSValue QuickTestUtil::typeName(const QVariant &v) const { QString name = QString::fromUtf8(v.typeName()); diff --git a/src/qmltest/quicktestutil_p.h b/src/qmltest/quicktestutil_p.h index 1cf2a6f356..fae904b84c 100644 --- a/src/qmltest/quicktestutil_p.h +++ b/src/qmltest/quicktestutil_p.h @@ -73,6 +73,8 @@ public: bool printAvailableFunctions() const; int dragThreshold() const; + Q_INVOKABLE void populateClipboardText(int lineCount); + Q_SIGNALS: void printAvailableFunctionsChanged(); void dragThresholdChanged(); |