Fix race condition in autotests
The QVector m_surface is modified in both threads. Change-Id: I1818a5e1307d191f1613513b86703eaa7bda3c6e Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
parent
49fc676e8b
commit
843c98d2d2
@ -220,12 +220,14 @@ QSharedPointer<MockSurface> MockCompositor::surface()
|
|||||||
{
|
{
|
||||||
QSharedPointer<MockSurface> result;
|
QSharedPointer<MockSurface> result;
|
||||||
lock();
|
lock();
|
||||||
QVector<Impl::Surface *> surfaces = m_compositor->surfaces();
|
{
|
||||||
foreach (Impl::Surface *surface, surfaces) {
|
QVector<Impl::Surface *> surfaces = m_compositor->surfaces();
|
||||||
// we don't want to mistake the cursor surface for a window surface
|
foreach (Impl::Surface *surface, surfaces) {
|
||||||
if (surface->isMapped()) {
|
// we don't want to mistake the cursor surface for a window surface
|
||||||
result = surface->mockSurface();
|
if (surface->isMapped()) {
|
||||||
break;
|
result = surface->mockSurface();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlock();
|
unlock();
|
||||||
@ -307,7 +309,7 @@ void *MockCompositor::run(void *data)
|
|||||||
{
|
{
|
||||||
MockCompositor *controller = static_cast<MockCompositor *>(data);
|
MockCompositor *controller = static_cast<MockCompositor *>(data);
|
||||||
|
|
||||||
Impl::Compositor compositor;
|
Impl::Compositor compositor(controller);
|
||||||
|
|
||||||
controller->m_compositor = &compositor;
|
controller->m_compositor = &compositor;
|
||||||
controller->m_waitCondition.wakeOne();
|
controller->m_waitCondition.wakeOne();
|
||||||
@ -332,8 +334,8 @@ void *MockCompositor::run(void *data)
|
|||||||
|
|
||||||
namespace Impl {
|
namespace Impl {
|
||||||
|
|
||||||
Compositor::Compositor()
|
Compositor::Compositor(MockCompositor *mockCompositor)
|
||||||
: m_display(wl_display_create())
|
: m_mockCompositor(mockCompositor), m_display(wl_display_create())
|
||||||
{
|
{
|
||||||
if (wl_display_add_socket(m_display, 0)) {
|
if (wl_display_add_socket(m_display, 0)) {
|
||||||
fprintf(stderr, "Fatal: Failed to open server socket\n");
|
fprintf(stderr, "Fatal: Failed to open server socket\n");
|
||||||
@ -445,15 +447,19 @@ uint32_t Compositor::nextSerial()
|
|||||||
|
|
||||||
void Compositor::addSurface(Surface *surface)
|
void Compositor::addSurface(Surface *surface)
|
||||||
{
|
{
|
||||||
|
m_mockCompositor->lock();
|
||||||
m_surfaces << surface;
|
m_surfaces << surface;
|
||||||
|
m_mockCompositor->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compositor::removeSurface(Surface *surface)
|
void Compositor::removeSurface(Surface *surface)
|
||||||
{
|
{
|
||||||
|
m_mockCompositor->lock();
|
||||||
m_surfaces.removeOne(surface);
|
m_surfaces.removeOne(surface);
|
||||||
m_keyboard->handleSurfaceDestroyed(surface);
|
m_keyboard->handleSurfaceDestroyed(surface);
|
||||||
m_pointer->handleSurfaceDestroyed(surface);
|
m_pointer->handleSurfaceDestroyed(surface);
|
||||||
m_fullScreenShellV1->removeSurface(surface);
|
m_fullScreenShellV1->removeSurface(surface);
|
||||||
|
m_mockCompositor->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface *Compositor::resolveSurface(const QVariant &v)
|
Surface *Compositor::resolveSurface(const QVariant &v)
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
|
||||||
|
class MockCompositor;
|
||||||
|
|
||||||
namespace Impl {
|
namespace Impl {
|
||||||
|
|
||||||
typedef void (**Implementation)(void);
|
typedef void (**Implementation)(void);
|
||||||
@ -63,7 +65,7 @@ class XdgShellV6;
|
|||||||
class Compositor
|
class Compositor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Compositor();
|
Compositor(MockCompositor *mockCompositor);
|
||||||
~Compositor();
|
~Compositor();
|
||||||
|
|
||||||
int fileDescriptor() const { return m_fd; }
|
int fileDescriptor() const { return m_fd; }
|
||||||
@ -114,6 +116,7 @@ private:
|
|||||||
|
|
||||||
void initShm();
|
void initShm();
|
||||||
|
|
||||||
|
MockCompositor *m_mockCompositor = nullptr;
|
||||||
QRect m_outputGeometry;
|
QRect m_outputGeometry;
|
||||||
|
|
||||||
wl_display *m_display = nullptr;
|
wl_display *m_display = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user