Kaydet (Commit) bf7776f0 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

vcl: protect more outdev functions for disposed state

This is similar to commit c612c3b0
(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/66403Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
(cherry picked from commit 8b461713)

Conflicts:
	vcl/qa/cppunit/outdev.cxx

Change-Id: I8021fb795704f19e52d70505804d68725c636ce0
Reviewed-on: https://gerrit.libreoffice.org/66455Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 763d490d
...@@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_outdev, \ ...@@ -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_externals,vcl_outdev,boost_headers))
$(eval $(call gb_CppunitTest_use_libraries,vcl_outdev, \ $(eval $(call gb_CppunitTest_use_libraries,vcl_outdev, \
basegfx \
comphelper \ comphelper \
cppu \ cppu \
cppuhelper \ cppuhelper \
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <vcl/pngwrite.hxx> #include <vcl/pngwrite.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
class VclOutdevTest : public test::BootstrapFixture class VclOutdevTest : public test::BootstrapFixture
{ {
...@@ -24,9 +25,11 @@ public: ...@@ -24,9 +25,11 @@ public:
VclOutdevTest() : BootstrapFixture(true, false) {} VclOutdevTest() : BootstrapFixture(true, false) {}
void testVirtualDevice(); void testVirtualDevice();
void testUseAfterDispose();
CPPUNIT_TEST_SUITE(VclOutdevTest); CPPUNIT_TEST_SUITE(VclOutdevTest);
CPPUNIT_TEST(testVirtualDevice); CPPUNIT_TEST(testVirtualDevice);
CPPUNIT_TEST(testUseAfterDispose);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -79,6 +82,21 @@ void VclOutdevTest::testVirtualDevice() ...@@ -79,6 +82,21 @@ void VclOutdevTest::testVirtualDevice()
#endif #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_TEST_SUITE_REGISTRATION(VclOutdevTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -850,7 +850,7 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode ) ...@@ -850,7 +850,7 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
// #i75163# // #i75163#
basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const
{ {
if(mbMap) if(mbMap && mpOutDevData)
{ {
if(!mpOutDevData->mpViewTransform) if(!mpOutDevData->mpViewTransform)
{ {
...@@ -878,7 +878,7 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const ...@@ -878,7 +878,7 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const
// #i75163# // #i75163#
basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation() const basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation() const
{ {
if(mbMap) if(mbMap && mpOutDevData)
{ {
if(!mpOutDevData->mpInverseViewTransform) if(!mpOutDevData->mpInverseViewTransform)
{ {
......
...@@ -723,6 +723,9 @@ bool OutputDevice::HasMirroredGraphics() const ...@@ -723,6 +723,9 @@ bool OutputDevice::HasMirroredGraphics() const
bool OutputDevice::ImplIsRecordLayout() const bool OutputDevice::ImplIsRecordLayout() const
{ {
if (!mpOutDevData)
return false;
return mpOutDevData->mpRecordLayout; return mpOutDevData->mpRecordLayout;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment