[src/server] Verify that surface has a resource before sending pointer enter

Summary:
If we try to send a pointer enter on a null resource of a Surface
(e.g. after unbound) we hit a marshalling error:
error marshalling arguments for enter (signature uoff): null value passed for arg 1

The added test case hits this error without the change and passes
cleanly with the change.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2159
This commit is contained in:
Martin Gräßlin 2016-07-14 11:45:38 +02:00
parent 53f27feee7
commit 253cb85fdb
2 changed files with 37 additions and 1 deletions

View file

@ -79,6 +79,7 @@ private Q_SLOTS:
void testSelection();
void testTouch();
void testDisconnect();
void testPointerEnterOnUnboundSurface();
// TODO: add test for keymap
private:
@ -1756,5 +1757,40 @@ void TestWaylandSeat::testDisconnect()
m_queue->destroy();
}
void TestWaylandSeat::testPointerEnterOnUnboundSurface()
{
using namespace KWayland::Client;
using namespace KWayland::Server;
// create the things we need
m_seatInterface->setHasKeyboard(true);
m_seatInterface->setHasPointer(true);
m_seatInterface->setHasTouch(true);
QSignalSpy pointerChangedSpy(m_seat, &Seat::hasPointerChanged);
QVERIFY(pointerChangedSpy.isValid());
QVERIFY(pointerChangedSpy.wait());
// create pointer and Surface
QScopedPointer<Pointer> pointer(m_seat->createPointer());
QVERIFY(!pointer.isNull());
// create the surface
QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated);
QVERIFY(surfaceCreatedSpy.isValid());
QScopedPointer<Surface> s(m_compositor->createSurface());
QVERIFY(surfaceCreatedSpy.wait());
SurfaceInterface *serverSurface = surfaceCreatedSpy.first().first().value<KWayland::Server::SurfaceInterface*>();
QVERIFY(serverSurface);
// unbind the surface again
QSignalSpy surfaceUnboundSpy(serverSurface, &SurfaceInterface::unbound);
QVERIFY(surfaceUnboundSpy.isValid());
s.reset();
QVERIFY(surfaceUnboundSpy.wait());
QSignalSpy clientErrorSpy(m_connection, &ConnectionThread::errorOccurred);
QVERIFY(clientErrorSpy.isValid());
m_seatInterface->setFocusedPointerSurface(serverSurface);
QVERIFY(!clientErrorSpy.wait(100));
}
QTEST_GUILESS_MAIN(TestWaylandSeat)
#include "test_wayland_seat.moc"

View file

@ -88,7 +88,7 @@ static QPointF surfacePosition(SurfaceInterface *surface) {
void PointerInterface::Private::sendEnter(SurfaceInterface *surface, const QPointF &parentSurfacePosition, quint32 serial)
{
if (!surface) {
if (!surface || !surface->resource()) {
return;
}
const QPointF adjustedPos = parentSurfacePosition - surfacePosition(surface);