diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-01-06 13:22:26 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-01-06 13:22:26 +0100 |
commit | fd6263e37641657f8bf81f42e72c7074263d277d (patch) | |
tree | e8378e9e8d7890499c7097daf324e289039469ac /svx/source/dialog/dlgctl3d.cxx | |
parent | cd103a888b8149aca66c7a93b91f8f7c2f1dbe31 (diff) |
Make E3dScene3D::GetCamera return non-reference
I stumbled over this when Valgrind'ing CppunitTest_sd_filters_test somewhat
erroneously reported
Source and destination overlap in memcpy(0x2fde4af8, 0x2fde4af8, 96)
for
aCamera = rNewCamera;
in E3dScene::SetCamera (svx/source/engine3d/scene3d.cxx), where the compiler
chose to use memcpy in the implicit definition of the Viewport3D (being a base
class of Camera3D) copy assignment operator, and the call pattern of
Get/SetCamera in EnhancedCustomShape3d::Create3DObject
(svx/source/customshapes/EnhancedCustomShape3d.cxx) causes that assignment to be
a self-assignment.
Upon closer inspection, some calls of GetCamera already create a copy from the
returned reference, while others modified the returned reference, but then would
also always call SetCamera on it. An alternative to the given change would have
been to instead change SetCamera(Camera3D&) to UpdateCamera() and require all
call sites of GetCamera/UpdateCamera to modify the reference returned from
GetCamera, but it looks safer overall to go this way.
Change-Id: I578e72db57630dca1b09124a3b11d177005b797d
Diffstat (limited to 'svx/source/dialog/dlgctl3d.cxx')
-rw-r--r-- | svx/source/dialog/dlgctl3d.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx index 2dbd53e6f72b..482a89d794ba 100644 --- a/svx/source/dialog/dlgctl3d.cxx +++ b/svx/source/dialog/dlgctl3d.cxx @@ -103,7 +103,7 @@ void Svx3DPreviewControl::Construct() SetObjectType(SvxPreviewObjectType::SPHERE); // camera and perspective - Camera3D& rCamera = (Camera3D&) mpScene->GetCamera(); + Camera3D rCamera = mpScene->GetCamera(); const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume(); double fW = rVolume.getWidth(); double fH = rVolume.getHeight(); @@ -341,7 +341,7 @@ void Svx3DLightControl::Construct2() { // change camera settings - Camera3D& rCamera = (Camera3D&) mpScene->GetCamera(); + Camera3D rCamera = mpScene->GetCamera(); const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume(); double fW = rVolume.getWidth(); double fH = rVolume.getHeight(); |