diff options
author | Noel Grandin <noel@peralex.com> | 2016-03-02 16:28:45 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-03-02 16:39:13 +0200 |
commit | 037de512546917786c313d23995daaa0521a8e6e (patch) | |
tree | 7bff7e3ad727708b6f44adc0753440c6f7813c6c /slideshow/source | |
parent | cdd7a0fe48aefee420d1f75b9dff04a26362773a (diff) |
tdf#98175 fix Impress crash
Caused by my commit f29c0b2b3e8861909fa2c6c37bf631ab01590541
"boost::shared_ptr->std::shared_ptr in slideshow"
where I foolishly converted
shared_from_this()
to
std::shared_ptr<Activity>((Activity*)this) )
all over the place, which is bad, I should have used
std::dynamic_pointer_cast<ViewEventHandler>(shared_from_this())
Ah, the joys of C++ memory management.
Change-Id: I9b538e78730c9107870f406cb8ba482d491dd568
Diffstat (limited to 'slideshow/source')
5 files changed, 8 insertions, 5 deletions
diff --git a/slideshow/source/engine/rehearsetimingsactivity.cxx b/slideshow/source/engine/rehearsetimingsactivity.cxx index eb3b835650c0..4dc66f19c109 100644 --- a/slideshow/source/engine/rehearsetimingsactivity.cxx +++ b/slideshow/source/engine/rehearsetimingsactivity.cxx @@ -217,7 +217,7 @@ void RehearseTimingsActivity::start() for_each_sprite( []( const ::cppcanvas::CustomSpriteSharedPtr& pSprite ) { return pSprite->show(); } ); - mrActivitiesQueue.addActivity( std::shared_ptr<Activity>(this) ); + mrActivitiesQueue.addActivity( std::dynamic_pointer_cast<Activity>(shared_from_this()) ); mpMouseHandler->reset(); mrEventMultiplexer.addClickHandler( diff --git a/slideshow/source/engine/shapes/drawinglayeranimation.cxx b/slideshow/source/engine/shapes/drawinglayeranimation.cxx index 5083a4a34ef1..08b53cef34ca 100644 --- a/slideshow/source/engine/shapes/drawinglayeranimation.cxx +++ b/slideshow/source/engine/shapes/drawinglayeranimation.cxx @@ -859,7 +859,7 @@ ActivityImpl::ActivityImpl( bool ActivityImpl::enableAnimations() { mbIsActive = true; - return maContext.mrActivitiesQueue.addActivity( ActivitySharedPtr(this) ); + return maContext.mrActivitiesQueue.addActivity( std::dynamic_pointer_cast<Activity>(shared_from_this()) ); } ActivityImpl::~ActivityImpl() diff --git a/slideshow/source/engine/shapes/intrinsicanimationactivity.cxx b/slideshow/source/engine/shapes/intrinsicanimationactivity.cxx index 8740272be899..dfefa44bad4f 100644 --- a/slideshow/source/engine/shapes/intrinsicanimationactivity.cxx +++ b/slideshow/source/engine/shapes/intrinsicanimationactivity.cxx @@ -248,7 +248,8 @@ namespace slideshow bool IntrinsicAnimationActivity::enableAnimations() { mbIsActive = true; - return maContext.mrActivitiesQueue.addActivity( ActivitySharedPtr(this) ); + return maContext.mrActivitiesQueue.addActivity( std::dynamic_pointer_cast<Activity>(shared_from_this()) ); + } diff --git a/slideshow/source/engine/transitions/slidechangebase.cxx b/slideshow/source/engine/transitions/slidechangebase.cxx index e5a24e8450a2..a13dd27be25f 100644 --- a/slideshow/source/engine/transitions/slidechangebase.cxx +++ b/slideshow/source/engine/transitions/slidechangebase.cxx @@ -176,7 +176,7 @@ void SlideChangeBase::prefetch( const AnimatableShapeSharedPtr&, return; // register ourselves for view change events - mrEventMultiplexer.addViewHandler( std::shared_ptr<ViewEventHandler>(this) ); + mrEventMultiplexer.addViewHandler( std::dynamic_pointer_cast<ViewEventHandler>(shared_from_this()) ); // init views and create slide bitmaps for( const auto& pView : mrViewContainer ) @@ -251,7 +251,7 @@ void SlideChangeBase::end() mbSpritesVisible = false; // remove also from event multiplexer, we're dead anyway - mrEventMultiplexer.removeViewHandler( std::shared_ptr<ViewEventHandler>(this) ); + mrEventMultiplexer.removeViewHandler( std::dynamic_pointer_cast<ViewEventHandler>(shared_from_this()) ); } bool SlideChangeBase::operator()( double nValue ) diff --git a/slideshow/source/inc/disposable.hxx b/slideshow/source/inc/disposable.hxx index c85e3698e953..f1f693a23e33 100644 --- a/slideshow/source/inc/disposable.hxx +++ b/slideshow/source/inc/disposable.hxx @@ -36,6 +36,8 @@ namespace slideshow */ class SharedPtrAble : public std::enable_shared_from_this<SharedPtrAble> { + public: + virtual ~SharedPtrAble() {} }; /** Disposable interface |