diff options
author | Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com> | 2015-12-09 21:39:29 +0000 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-12-12 09:31:26 +0100 |
commit | c319cb0023ae4ab496b7d03f72c9f19864f29b57 (patch) | |
tree | f2449fc4b8ace8ef9007d65fa82c794c074009f7 /slideshow/source | |
parent | 130c85b54928c025d18bc19a2a155eb85b742675 (diff) |
slideshow: Don’t crash when a transition fails to initialize.
Instead replace it with no transition at all.
Change-Id: If7085e2ecd79eda80097f96bebbb2f9d11161c22
(cherry picked from commit 9e991f43e57d7a74fa2db10a46021cbe2218ac5a)
Diffstat (limited to 'slideshow/source')
3 files changed, 27 insertions, 22 deletions
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx index d277aa26b7db..e7065c8cd7b6 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx @@ -137,9 +137,11 @@ static std::vector<int> uploadPrimitives(const Primitives_t& primitives) return indices; } -void OGLTransitionImpl::prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex ) +bool OGLTransitionImpl::prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex ) { m_nProgramObject = makeShader(); + if (!m_nProgramObject) + return false; const SceneObjects_t& rSceneObjects(maScene.getSceneObjects()); for(size_t i(0); i != rSceneObjects.size(); ++i) { @@ -205,6 +207,7 @@ void OGLTransitionImpl::prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteri CHECK_GL_ERROR(); prepareTransition( glLeavingSlideTex, glEnteringSlideTex ); + return true; } void OGLTransitionImpl::finish() diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx index f33968528f37..2b9daa50b007 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx @@ -140,7 +140,7 @@ public: /** Prepare transition. */ - void prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex ); + bool prepare( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex ); /** Display a step of the transition. */ void display( double nTime, sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ); diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx index 5788a0c07290..9bd4476f2a93 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx @@ -175,7 +175,7 @@ class OGLTransitionerImpl : private cppu::BaseMutex, private boost::noncopyable, { public: OGLTransitionerImpl(); - void setTransition( std::shared_ptr<OGLTransitionImpl> pOGLTransition ); + bool setTransition( std::shared_ptr<OGLTransitionImpl> pOGLTransition ); bool initialize( const Reference< presentation::XSlideShowView >& xView, const Reference< rendering::XBitmap >& xLeavingSlide, const Reference< rendering::XBitmap >& xEnteringSlide ); @@ -224,7 +224,7 @@ private: */ void GLInitSlides(); - void impl_prepareTransition(); + bool impl_prepareTransition(); void impl_finishTransition(); private: @@ -529,10 +529,11 @@ void OGLTransitionerImpl::impl_prepareSlides() #endif } -void OGLTransitionerImpl::impl_prepareTransition() +bool OGLTransitionerImpl::impl_prepareTransition() { if( mpTransition && mpTransition->getSettings().mnRequiredGLVersion <= mnGLVersion ) - mpTransition->prepare( maLeavingSlideGL, maEnteringSlideGL ); + return mpTransition->prepare( maLeavingSlideGL, maEnteringSlideGL ); + return false; } void OGLTransitionerImpl::impl_finishTransition() @@ -541,15 +542,21 @@ void OGLTransitionerImpl::impl_finishTransition() mpTransition->finish(); } -void OGLTransitionerImpl::setTransition( std::shared_ptr<OGLTransitionImpl> pTransition ) +bool OGLTransitionerImpl::setTransition( std::shared_ptr<OGLTransitionImpl> pTransition ) { if ( mpTransition ) // already initialized - return; + return true; mpTransition = pTransition; + bool succeeded = impl_prepareTransition(); + if (!succeeded) { + mpTransition = nullptr; + return false; + } + impl_prepareSlides(); - impl_prepareTransition(); + return true; } void OGLTransitionerImpl::createTexture( GLuint* texID, @@ -1138,7 +1145,7 @@ void OGLTransitionerImpl::GLInitSlides() { osl::MutexGuard const guard( m_aMutex ); - if (isDisposed() || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion) + if (isDisposed() || !mpTransition || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion) return; #if OSL_DEBUG_LEVEL > 1 @@ -1187,7 +1194,7 @@ void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeExc #endif osl::MutexGuard const guard( m_aMutex ); - if (isDisposed() || !mbValidOpenGLContext || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion) + if (isDisposed() || !mbValidOpenGLContext || !mpTransition || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion) return; mpContext->makeCurrent(); @@ -1197,14 +1204,11 @@ void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeExc glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); CHECK_GL_ERROR(); - if(mpTransition) - { - const GLWindow& rGLWindow(mpContext->getOpenGLWindow()); - mpTransition->display( nTime, maLeavingSlideGL, maEnteringSlideGL, - maSlideSize.Width, maSlideSize.Height, - static_cast<double>(rGLWindow.Width), - static_cast<double>(rGLWindow.Height) ); - } + const GLWindow& rGLWindow(mpContext->getOpenGLWindow()); + mpTransition->display( nTime, maLeavingSlideGL, maEnteringSlideGL, + maSlideSize.Width, maSlideSize.Height, + static_cast<double>(rGLWindow.Width), + static_cast<double>(rGLWindow.Height) ); mpContext->swapBuffers(); @@ -1502,11 +1506,9 @@ public: pTransition = makeNewsflash(); } - if ( !pTransition ) + if ( !pTransition || !xRes->setTransition(pTransition) ) return uno::Reference< presentation::XTransition >(); - xRes->setTransition( pTransition ); - return uno::Reference<presentation::XTransition>(xRes.get()); } }; |