# HG changeset patch # User Benjamin Golinvaux # Date 1566548192 -7200 # Node ID 769249e1f3b424d04eb57e6c95e2487120c670f8 # Parent 966c96b694f69f5a18dec29a15e262eb159e89cf added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix diff -r 966c96b694f6 -r 769249e1f3b4 Framework/Fonts/GlyphTextureAlphabet.cpp --- a/Framework/Fonts/GlyphTextureAlphabet.cpp Wed Aug 21 16:24:57 2019 +0200 +++ b/Framework/Fonts/GlyphTextureAlphabet.cpp Fri Aug 23 10:16:32 2019 +0200 @@ -28,9 +28,18 @@ #include #include +#ifdef __EMSCRIPTEN__ +/* +Avoid this error: +.../boost/math/special_functions/round.hpp:86:12: warning: implicit conversion from 'std::__2::numeric_limits::type' (aka 'int') to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-int-float-conversion] +.../boost/math/special_functions/round.hpp:93:11: note: in instantiation of function template specialization 'boost::math::iround >' requested here +.../orthanc-stone/Framework/Fonts/GlyphTextureAlphabet.cpp:92:28: note: in instantiation of function template specialization 'boost::math::iround' requested here +*/ +#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" +#endif + #include - namespace OrthancStone { class GlyphTextureAlphabet::GlyphSizeVisitor : public GlyphAlphabet::IGlyphVisitor diff -r 966c96b694f6 -r 769249e1f3b4 Framework/OpenGL/WebAssemblyOpenGLContext.cpp --- a/Framework/OpenGL/WebAssemblyOpenGLContext.cpp Wed Aug 21 16:24:57 2019 +0200 +++ b/Framework/OpenGL/WebAssemblyOpenGLContext.cpp Fri Aug 23 10:16:32 2019 +0200 @@ -71,7 +71,7 @@ bool IsContextLost() { - LOG(TRACE) << "IsContextLost() for context " << std::hex() << + LOG(TRACE) << "IsContextLost() for context " << std::hex << context_ << std::dec; bool apiFlag = (emscripten_is_webgl_context_lost(context_) != 0); isContextLost_ = apiFlag; return isContextLost_; diff -r 966c96b694f6 -r 769249e1f3b4 Framework/Scene2D/RotateSceneTracker.cpp --- 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_); + } } } diff -r 966c96b694f6 -r 769249e1f3b4 Framework/Scene2D/ZoomSceneTracker.cpp --- a/Framework/Scene2D/ZoomSceneTracker.cpp Wed Aug 21 16:24:57 2019 +0200 +++ b/Framework/Scene2D/ZoomSceneTracker.cpp Fri Aug 23 10:16:32 2019 +0200 @@ -76,17 +76,26 @@ double zoom = pow(2.0, z); - GetController()->SetSceneToCanvasTransform( - AffineTransform2D::Combine( - AffineTransform2D::CreateScaling(zoom, zoom), - originalSceneToCanvas_)); + // The controller is a weak pointer. It could be deleted when the + // tracker is still alive (for instance, because of a lost WebGL + // context) + if(GetController().get() != NULL) + { + GetController()->SetSceneToCanvasTransform( + AffineTransform2D::Combine( + AffineTransform2D::CreateScaling(zoom, zoom), + originalSceneToCanvas_)); - aligner_.Apply(); + aligner_.Apply(); + } } } void ZoomSceneTracker::Cancel() { - GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); + if(GetController().get() != NULL) + { + GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); + } } }