Skip to content

Commit 99e9bdc

Browse files
authored
Fixed excessive events sending from Qt to js side (#471)
1 parent a3330f3 commit 99e9bdc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ReactQt/runtime/src/rootview.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class RootViewPrivate : public QObject {
5353
RootView* q_ptr;
5454
bool remoteJSDebugging = false;
5555
QNetworkReply* liveReloadUrlReply = nullptr;
56+
QSet<ulong> m_processedEvents;
5657

5758
RootViewPrivate(RootView* q) : q_ptr(q) {}
5859

@@ -330,13 +331,20 @@ void RootView::componentComplete() {
330331
void RootView::sendMouseEvent(QMouseEvent* event, const QString& eventType, QQuickItem* receiver) {
331332
Q_D(RootView);
332333

334+
if (d->m_processedEvents.contains(event->timestamp())) {
335+
return;
336+
} else {
337+
d->m_processedEvents.clear();
338+
}
339+
333340
QVariantMap e = makeReactTouchEvent(receiver, event);
334341
if (e.isEmpty())
335342
return;
336343

337344
d->bridge->enqueueJSCall("RCTEventEmitter",
338345
"receiveTouches",
339346
QVariantList{normalizeInputEventName(eventType), QVariantList{e}, QVariantList{0}});
347+
d->m_processedEvents.insert(event->timestamp());
340348
event->setAccepted(true);
341349
}
342350

0 commit comments

Comments
 (0)