qml: fix race condition while initializing FlickableScrollHandler

fix: #27890
This commit is contained in:
Pierre Lamot 2023-02-27 11:18:24 +01:00 committed by Jean-Baptiste Kempf
parent 71c6ce8d05
commit 705f53e985
2 changed files with 12 additions and 6 deletions

View File

@ -34,8 +34,6 @@ FlickableScrollHandler::FlickableScrollHandler(QObject *parent)
});
setScaleFactor(1.0);
QMetaObject::invokeMethod(this, &FlickableScrollHandler::init, Qt::QueuedConnection);
}
FlickableScrollHandler::~FlickableScrollHandler()
@ -43,7 +41,11 @@ FlickableScrollHandler::~FlickableScrollHandler()
detach();
}
void FlickableScrollHandler::init()
void FlickableScrollHandler::classBegin()
{
}
void FlickableScrollHandler::componentComplete()
{
assert(parent());

View File

@ -22,8 +22,9 @@
#include <QQmlProperty>
#include <QPointer>
#include <QQuickItem>
#include <QQmlParserStatus>
class FlickableScrollHandler : public QObject
class FlickableScrollHandler : public QObject, public QQmlParserStatus
{
Q_OBJECT
@ -35,6 +36,8 @@ class FlickableScrollHandler : public QObject
Q_PROPERTY(bool fallbackScroll MEMBER m_fallbackScroll NOTIFY fallbackScrollChanged FINAL)
Q_PROPERTY(bool handleOnlyPixelDelta MEMBER m_handleOnlyPixelDelta NOTIFY handleOnlyPixelDeltaChanged FINAL)
Q_INTERFACES(QQmlParserStatus)
public:
explicit FlickableScrollHandler(QObject *parent = nullptr);
~FlickableScrollHandler();
@ -46,6 +49,9 @@ public:
void setScaleFactor(qreal newScaleFactor);
void setEnabled(bool newEnabled);
void classBegin() override;
void componentComplete() override;
signals:
void initialized();
@ -57,8 +63,6 @@ signals:
void handleOnlyPixelDeltaChanged();
private slots:
void init();
void adjustScrollBarV();
void adjustScrollBarH();