]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsLoader.cpp
Avoid null pointer dereference
[lyx.git] / src / graphics / GraphicsLoader.cpp
index 683f0925fc603a8e2b8b4687fcf9bd3fc0e5d67b..dc3f7c5e357672e315934797408e5e4d0112693d 100644 (file)
@@ -21,8 +21,7 @@
 #include "support/lassert.h"
 #include "support/Timeout.h"
 
-#include "support/bind.h"
-
+#include <list>
 #include <queue>
 #include <memory>
 #include <set>
@@ -193,9 +192,9 @@ public:
        /// We modify a local copy of the image once it is loaded.
        ImagePtr image_;
        /// This signal is emitted when the image loading status changes.
-       signals2::signal<void()> signal_;
+       signal<void()> signal_;
        /// The connection of the signal statusChanged
-       signals2::scoped_connection connection_;
+       scoped_connection connection_;
 
        double displayPixelRatio() const
        {
@@ -299,7 +298,8 @@ void Loader::reset(Params const & params) const
 
 void Loader::startLoading() const
 {
-       if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_)
+       if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_
+           || pimpl_->cached_item_->status() == Converting)
                return;
        pimpl_->startLoading();
 }
@@ -364,7 +364,7 @@ void Loader::setDisplayPixelRatio(double scale)
 }
 
 
-signals2::connection Loader::connect(slot const & slot) const
+connection Loader::connect(slot const & slot) const
 {
        return pimpl_->signal_.connect(slot);
 }
@@ -400,7 +400,7 @@ void Loader::Impl::resetFile(FileName const & file)
        // new file.
        bool continue_monitoring = false;
 
-       if (!old_file.empty()) {
+       if (cached_item_ && !old_file.empty()) {
                continue_monitoring = cached_item_->monitoring();
                // cached_item_ is going to be reset, so the connected
                // signal needs to be disconnected.