autotests: Fix ASAN issues in TestWaylandSurface::testStaticAccessor
We need to store surface ids before destroying the corresponding surfaces in order to avoid heap-use-after-free errors.
This commit is contained in:
parent
4ef47641ed
commit
456106d749
1 changed files with 5 additions and 2 deletions
|
@ -224,6 +224,9 @@ void TestWaylandSurface::testStaticAccessor()
|
||||||
QCOMPARE(KWaylandServer::SurfaceInterface::get(serverSurface2->resource()), serverSurface2);
|
QCOMPARE(KWaylandServer::SurfaceInterface::get(serverSurface2->resource()), serverSurface2);
|
||||||
QCOMPARE(KWaylandServer::SurfaceInterface::get(serverSurface2->id(), serverSurface2->client()), serverSurface2);
|
QCOMPARE(KWaylandServer::SurfaceInterface::get(serverSurface2->id(), serverSurface2->client()), serverSurface2);
|
||||||
|
|
||||||
|
const quint32 surfaceId1 = serverSurface1->id();
|
||||||
|
const quint32 surfaceId2 = serverSurface2->id();
|
||||||
|
|
||||||
// delete s2 again
|
// delete s2 again
|
||||||
delete s2;
|
delete s2;
|
||||||
QCOMPARE(KWayland::Client::Surface::all().count(), 1);
|
QCOMPARE(KWayland::Client::Surface::all().count(), 1);
|
||||||
|
@ -238,8 +241,8 @@ void TestWaylandSurface::testStaticAccessor()
|
||||||
QVERIFY(destroyedSpy.isValid());
|
QVERIFY(destroyedSpy.isValid());
|
||||||
QVERIFY(destroyedSpy.wait());
|
QVERIFY(destroyedSpy.wait());
|
||||||
QVERIFY(!KWaylandServer::SurfaceInterface::get(nullptr));
|
QVERIFY(!KWaylandServer::SurfaceInterface::get(nullptr));
|
||||||
QVERIFY(!KWaylandServer::SurfaceInterface::get(serverSurface1->id(), nullptr));
|
QVERIFY(!KWaylandServer::SurfaceInterface::get(surfaceId1, nullptr));
|
||||||
QVERIFY(!KWaylandServer::SurfaceInterface::get(serverSurface2->id(), nullptr));
|
QVERIFY(!KWaylandServer::SurfaceInterface::get(surfaceId2, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestWaylandSurface::testDamage()
|
void TestWaylandSurface::testDamage()
|
||||||
|
|
Loading…
Reference in a new issue