diff --git a/autotests/drm/drmTest.cpp b/autotests/drm/drmTest.cpp index dcdd5d07fa..a8a58bb3e3 100644 --- a/autotests/drm/drmTest.cpp +++ b/autotests/drm/drmTest.cpp @@ -38,6 +38,7 @@ private Q_SLOTS: void testZeroModesHandling(); void testModeGeneration_data(); void testModeGeneration(); + void testConnectorLifetime(); }; static void verifyCleanup(MockGpu *mockGpu) @@ -279,5 +280,32 @@ void DrmTest::testModeGeneration() verifyCleanup(mockGpu.get()); } +void DrmTest::testConnectorLifetime() +{ + // don't crash if output lifetime is extended beyond the connector + const auto mockGpu = std::make_unique(1, 5); + + const auto conn = std::make_shared(mockGpu.get()); + mockGpu->connectors.push_back(conn); + + const auto session = Session::create(Session::Type::Noop); + const auto backend = std::make_unique(session.get()); + const auto renderBackend = backend->createQPainterBackend(); + auto gpu = std::make_unique(backend.get(), "test", 1, 0); + + QVERIFY(gpu->updateOutputs()); + QCOMPARE(gpu->drmOutputs().size(), 1); + + DrmOutput *const output = gpu->drmOutputs().front(); + + output->ref(); + mockGpu->connectors.clear(); + QVERIFY(gpu->updateOutputs()); + output->unref(); + + gpu.reset(); + verifyCleanup(mockGpu.get()); +} + QTEST_GUILESS_MAIN(DrmTest) #include "drmTest.moc"