]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphics.C
ws changes only
[lyx.git] / src / insets / insetgraphics.C
index f3c3493c264fda958bd4beff04abe234fe2287fa..43128342690f21076c3a5ac11d9cf0ae9afff393 100644 (file)
@@ -66,8 +66,10 @@ TODO
 #include "latexrunparams.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
+#include "frontends/LyXView.h"
 
 #include "support/filetools.h"
 #include "support/lyxalgo.h" // lyx::count
@@ -181,9 +183,21 @@ InsetGraphics::~InsetGraphics()
 }
 
 
+void InsetGraphics::cache(BufferView * view) const
+{
+       BOOST_ASSERT(view);
+       view_ = view->owner()->view();
+}
+
+BufferView * InsetGraphics::view() const
+{
+       return view_.lock().get();
+}
+
+
 void InsetGraphics::statusChanged() const
 {
-       BufferView * bv = graphic_->view();
+       BufferView * bv = view();
        if (bv)
                bv->updateInset(this);
 }
@@ -213,7 +227,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
                return DISPATCHED;
 
        default:
-               return InsetOld::localDispatch(cmd);
+               return UNDISPATCHED;
        }
 }
 
@@ -227,6 +241,7 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
 {
+       cache(pi.base.bv);
        graphic_->draw(pi, x, y);
 }