]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsLoader.cpp
only called once
[lyx.git] / src / graphics / GraphicsLoader.cpp
index 14df775328cc957ddff49b0005132015d3fb3d1e..a7ac094cd2e69690deafb0c776e15504b89a1ab7 100644 (file)
@@ -29,6 +29,8 @@ using support::FileName;
 
 namespace graphics {
 
+typedef boost::shared_ptr<Image> ImagePtr;
+
 class Loader::Impl : public boost::signals::trackable {
 public:
        ///
@@ -53,9 +55,11 @@ public:
         */
        Cache::ItemPtr cached_item_;
        /// We modify a local copy of the image once it is loaded.
-       Image::ImagePtr 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:
        ///
@@ -96,7 +100,9 @@ Loader::Loader(Loader const & other)
 
 
 Loader::~Loader()
-{}
+{
+       delete pimpl_;
+}
 
 
 Loader & Loader::operator=(Loader const & other)
@@ -222,6 +228,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 +252,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));
 }