Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
957:966c96b694f6 | 958:769249e1f3b4 |
---|---|
48 { | 48 { |
49 referenceAngle_ = a; | 49 referenceAngle_ = a; |
50 isFirst_ = false; | 50 isFirst_ = false; |
51 } | 51 } |
52 | 52 |
53 GetController()->SetSceneToCanvasTransform( | 53 // The controller is a weak pointer. It could be deleted when the |
54 AffineTransform2D::Combine( | 54 // tracker is still alive (for instance, because of a lost WebGL |
55 AffineTransform2D::CreateRotation(a - referenceAngle_), | 55 // context that triggers a recreation of the viewport) |
56 originalSceneToCanvas_)); | 56 if(GetController().get() != NULL) |
57 | 57 { |
58 aligner_.Apply(); | 58 GetController()->SetSceneToCanvasTransform( |
59 AffineTransform2D::Combine( | |
60 AffineTransform2D::CreateRotation(a - referenceAngle_), | |
61 originalSceneToCanvas_)); | |
62 | |
63 aligner_.Apply(); | |
64 } | |
59 } | 65 } |
60 } | 66 } |
61 | 67 |
62 void RotateSceneTracker::Cancel() | 68 void RotateSceneTracker::Cancel() |
63 { | 69 { |
64 GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); | 70 // See remark above |
71 if(GetController().get() != NULL) | |
72 { | |
73 GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); | |
74 } | |
65 } | 75 } |
66 | 76 |
67 } | 77 } |