vcl/CppunitTest_vcl_outdev.mk | 1 + vcl/qa/cppunit/outdev.cxx | 18 ++++++++++++++++++ vcl/source/outdev/map.cxx | 4 ++-- vcl/source/outdev/outdev.cxx | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-)
New commits: commit bf7776f0909a087859d38a1115dc6d145bf24537 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Jan 15 17:31:16 2019 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Thu Jan 17 13:37:34 2019 +0100 vcl: protect more outdev functions for disposed state This is similar to commit c612c3b0aed9ad7f7f42b4313f821b71995ead15 (protect more printer code-paths., 2015-03-20), but handles more OutputDevice member functions. The user-level problem was that in case a macro creates a dialog with an embedded Chart document and the user clicks on e.g. the chart title (so an sdr::overlay::OverlayManager is created), then it can happen during closing the dialog that the overlay manager calls these functions after the output device is disposed. Reviewed-on: https://gerrit.libreoffice.org/66403 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 8b461713c0c86bc19af739aada4b1345cfa5dfbe) Conflicts: vcl/qa/cppunit/outdev.cxx Change-Id: I8021fb795704f19e52d70505804d68725c636ce0 Reviewed-on: https://gerrit.libreoffice.org/66455 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/vcl/CppunitTest_vcl_outdev.mk b/vcl/CppunitTest_vcl_outdev.mk index 183432fccfe6..f15d2e26d17d 100644 --- a/vcl/CppunitTest_vcl_outdev.mk +++ b/vcl/CppunitTest_vcl_outdev.mk @@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_outdev, \ $(eval $(call gb_CppunitTest_use_externals,vcl_outdev,boost_headers)) $(eval $(call gb_CppunitTest_use_libraries,vcl_outdev, \ + basegfx \ comphelper \ cppu \ cppuhelper \ diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 1e6508789574..dc88848463f0 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -17,6 +17,7 @@ #include <tools/stream.hxx> #include <vcl/pngwrite.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> class VclOutdevTest : public test::BootstrapFixture { @@ -24,9 +25,11 @@ public: VclOutdevTest() : BootstrapFixture(true, false) {} void testVirtualDevice(); + void testUseAfterDispose(); CPPUNIT_TEST_SUITE(VclOutdevTest); CPPUNIT_TEST(testVirtualDevice); + CPPUNIT_TEST(testUseAfterDispose); CPPUNIT_TEST_SUITE_END(); }; @@ -79,6 +82,21 @@ void VclOutdevTest::testVirtualDevice() #endif } +void VclOutdevTest::testUseAfterDispose() +{ + // Create a virtual device, enable map mode then dispose it. + ScopedVclPtrInstance<VirtualDevice> pVDev; + + pVDev->EnableMapMode(); + + pVDev->disposeOnce(); + + // Make sure that these don't crash after dispose. + pVDev->GetInverseViewTransformation(); + + pVDev->GetViewTransformation(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 1b1be1fe44f3..dbb79e80b835 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -850,7 +850,7 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode ) // #i75163# basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const { - if(mbMap) + if(mbMap && mpOutDevData) { if(!mpOutDevData->mpViewTransform) { @@ -878,7 +878,7 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const // #i75163# basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation() const { - if(mbMap) + if(mbMap && mpOutDevData) { if(!mpOutDevData->mpInverseViewTransform) { diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index e2218fb2c68e..8e9881728048 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -723,6 +723,9 @@ bool OutputDevice::HasMirroredGraphics() const bool OutputDevice::ImplIsRecordLayout() const { + if (!mpOutDevData) + return false; + return mpOutDevData->mpRecordLayout; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits