[Libreoffice-commits] core.git: vcl/CppunitTest_vcl_outdev.mk vcl/qa vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 15 22:22:36 UTC 2019
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 8b461713c0c86bc19af739aada4b1345cfa5dfbe
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jan 15 17:31:16 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jan 15 23:22:11 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.
Change-Id: I8021fb795704f19e52d70505804d68725c636ce0
Reviewed-on: https://gerrit.libreoffice.org/66403
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
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 c50481cb0f5a..cf6ee60a486a 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -18,6 +18,7 @@
#include <tools/stream.hxx>
#include <vcl/pngwrite.hxx>
#include <sal/log.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
class VclOutdevTest : public test::BootstrapFixture
{
@@ -25,9 +26,11 @@ public:
VclOutdevTest() : BootstrapFixture(true, false) {}
void testVirtualDevice();
+ void testUseAfterDispose();
CPPUNIT_TEST_SUITE(VclOutdevTest);
CPPUNIT_TEST(testVirtualDevice);
+ CPPUNIT_TEST(testUseAfterDispose);
CPPUNIT_TEST_SUITE_END();
};
@@ -80,6 +83,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 4c12160e19e7..0c8292b3dd93 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -856,7 +856,7 @@ void OutputDevice::SetRelativeMapMode( const MapMode& rNewMapMode )
// #i75163#
basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const
{
- if(mbMap)
+ if(mbMap && mpOutDevData)
{
if(!mpOutDevData->mpViewTransform)
{
@@ -884,7 +884,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 9e03be3d3454..65db4d0a51ef 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -660,6 +660,9 @@ bool OutputDevice::HasMirroredGraphics() const
bool OutputDevice::ImplIsRecordLayout() const
{
+ if (!mpOutDevData)
+ return false;
+
return mpOutDevData->mpRecordLayout;
}
More information about the Libreoffice-commits
mailing list