MockCompositor: Fix potential race condition

The list m_viewports is being accessed from both the main thread
and the dispatch thread. This has not been observed to cause any
errors, but is a potential source of test instability. Using a
DirectConnection makes sure that both appending and removal
happens in the same thread.

Task-number: QTBUG-130627
Pick-to: 6.8
Change-Id: Iee6941d8794119e679a485778f0be5c40df27069
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Paul Olav Tvete 2024-11-11 09:53:00 +01:00
parent 9fd572be56
commit 9aa5f633d4

View File

@ -16,7 +16,7 @@ void Viewporter::wp_viewporter_get_viewport(Resource *resource, uint32_t id, wl_
auto *viewport = new Viewport(s, resource->client(), id, resource->version());
connect(viewport, &QObject::destroyed, this, [this, viewport]() {
m_viewports.removeOne(viewport);
});
}, Qt::DirectConnection);
m_viewports << viewport;
}