]> git.lyx.org Git - lyx.git/commitdiff
Fix crash when a user removes the underlying figure of a graphic inset that has...
authorBo Peng <bpeng@lyx.org>
Thu, 16 Aug 2007 18:37:38 +0000 (18:37 +0000)
committerBo Peng <bpeng@lyx.org>
Thu, 16 Aug 2007 18:37:38 +0000 (18:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19612 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/GraphicsLoader.cpp
src/insets/RenderGraphic.cpp
src/insets/RenderGraphic.h

index 14df775328cc957ddff49b0005132015d3fb3d1e..1863725a7f01e0a8bbd69ba2cb7e28b4bb61821f 100644 (file)
@@ -56,6 +56,8 @@ public:
        Image::ImagePtr image_;
        /// This signal is emitted when the image loading status changes.
        boost::signal<void()> 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));
 }
 
 
index f8e0d2407556d98a0f7a0ac6f405e57949000ae0..3e9232edf23c14320727eb95e300184edc375c10 100644 (file)
@@ -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));
 }
 
index 7bbb87496c852fafae5f15f290085e7c7ee53a80..49db0e2c1f8d6b227f599b408e50beb7c5129ed0 100644 (file)
@@ -17,7 +17,6 @@
 #include "graphics/GraphicsLoader.h"
 #include "graphics/GraphicsParams.h"
 
-#include <boost/signal.hpp>
 
 namespace lyx {
 
@@ -29,8 +28,6 @@ public:
        RenderGraphic(RenderGraphic const &, Inset const *);
        std::auto_ptr<RenderBase> 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_;
 };