diff --git a/sd/qa/unit/data/tdf159666.odg b/sd/qa/unit/data/tdf159666.odg new file mode 100644 index 000000000000..6b407597f7ca Binary files /dev/null and b/sd/qa/unit/data/tdf159666.odg differ diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 41c685feef36..d03e85dab6c8 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -288,6 +288,27 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf124708) CPPUNIT_ASSERT_EQUAL(static_cast(16), pActualPage->GetObjCount()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf159666) +{ + createSdDrawDoc("tdf159666.odg"); + + auto pXImpressDocument = dynamic_cast(mxComponent.get()); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + CPPUNIT_ASSERT_EQUAL(static_cast(12), pActualPage->GetObjCount()); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + dispatchCommand(mxComponent, ".uno:Delete", {}); + + CPPUNIT_ASSERT_EQUAL(static_cast(0), pActualPage->GetObjCount()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + + CPPUNIT_ASSERT_EQUAL(static_cast(12), pActualPage->GetObjCount()); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf143412) { createSdImpressDoc();