Mercurial > hg > orthanc-stone
diff Framework/Scene2D/RotateSceneTracker.cpp @ 958:769249e1f3b4
added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 23 Aug 2019 10:16:32 +0200 |
parents | e42b491f1fb2 |
children | 2d8ab34c8c91 |
line wrap: on
line diff
--- a/Framework/Scene2D/RotateSceneTracker.cpp Wed Aug 21 16:24:57 2019 +0200 +++ b/Framework/Scene2D/RotateSceneTracker.cpp Fri Aug 23 10:16:32 2019 +0200 @@ -50,18 +50,28 @@ isFirst_ = false; } - GetController()->SetSceneToCanvasTransform( - AffineTransform2D::Combine( - AffineTransform2D::CreateRotation(a - referenceAngle_), - originalSceneToCanvas_)); - - aligner_.Apply(); + // The controller is a weak pointer. It could be deleted when the + // tracker is still alive (for instance, because of a lost WebGL + // context that triggers a recreation of the viewport) + if(GetController().get() != NULL) + { + GetController()->SetSceneToCanvasTransform( + AffineTransform2D::Combine( + AffineTransform2D::CreateRotation(a - referenceAngle_), + originalSceneToCanvas_)); + + aligner_.Apply(); + } } } void RotateSceneTracker::Cancel() { - GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); + // See remark above + if(GetController().get() != NULL) + { + GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); + } } }