From 81031b4cea5d57f4831208ef69b85ea1fc1911d5 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Thu, 16 Aug 2007 18:37:38 +0000 Subject: [PATCH] Fix crash when a user removes the underlying figure of a graphic inset that has been copied and pasted (Bug 4108). Revert Andel's fix r19591 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19612 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/graphics/GraphicsLoader.cpp | 7 ++++++- src/insets/RenderGraphic.cpp | 4 ++-- src/insets/RenderGraphic.h | 6 ------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp index 14df775328..1863725a7f 100644 --- a/src/graphics/GraphicsLoader.cpp +++ b/src/graphics/GraphicsLoader.cpp @@ -56,6 +56,8 @@ public: Image::ImagePtr image_; /// This signal is emitted when the image loading status changes. boost::signal signal_; + /// The connection of the signal StatusChanged + boost::signals::connection sc_; private: /// @@ -222,6 +224,9 @@ void Loader::Impl::resetFile(FileName const & file) if (!old_file.empty()) { continue_monitoring = cached_item_->monitoring(); + // cached_item_ is going to be reset, so the connected + // signal needs to be disconnected. + sc_.disconnect(); cached_item_.reset(); Cache::get().remove(old_file); } @@ -243,7 +248,7 @@ void Loader::Impl::resetFile(FileName const & file) if (continue_monitoring && !cached_item_->monitoring()) cached_item_->startMonitoring(); - cached_item_->connect(boost::bind(&Impl::statusChanged, this)); + sc_ = cached_item_->connect(boost::bind(&Impl::statusChanged, this)); } diff --git a/src/insets/RenderGraphic.cpp b/src/insets/RenderGraphic.cpp index f8e0d24075..3e9232edf2 100644 --- a/src/insets/RenderGraphic.cpp +++ b/src/insets/RenderGraphic.cpp @@ -40,7 +40,7 @@ using std::auto_ptr; RenderGraphic::RenderGraphic(Inset const * inset) { - loader_connection_ = loader_.connect(boost::bind(&LyX::updateInset, + loader_.connect(boost::bind(&LyX::updateInset, boost::cref(LyX::cref()), inset)); } @@ -51,7 +51,7 @@ RenderGraphic::RenderGraphic(RenderGraphic const & other, loader_(other.loader_), params_(other.params_) { - loader_connection_ = loader_.connect(boost::bind(&LyX::updateInset, + loader_.connect(boost::bind(&LyX::updateInset, boost::cref(LyX::cref()), inset)); } diff --git a/src/insets/RenderGraphic.h b/src/insets/RenderGraphic.h index 7bbb87496c..49db0e2c1f 100644 --- a/src/insets/RenderGraphic.h +++ b/src/insets/RenderGraphic.h @@ -17,7 +17,6 @@ #include "graphics/GraphicsLoader.h" #include "graphics/GraphicsParams.h" -#include namespace lyx { @@ -29,8 +28,6 @@ public: RenderGraphic(RenderGraphic const &, Inset const *); std::auto_ptr clone(Inset const *) const; - ~RenderGraphic() { loader_connection_.disconnect(); } - /// compute the size of the object returned in dim bool metrics(MetricsInfo & mi, Dimension & dim) const; /// draw inset @@ -49,9 +46,6 @@ private: /// The stored data. graphics::Loader loader_; graphics::Params params_; - - // - boost::signals::connection loader_connection_; }; -- 2.39.2