]> git.lyx.org Git - lyx.git/commitdiff
Fix first insert of external material & instant preview.
authorPavel Sanda <sanda@lyx.org>
Sun, 21 Dec 2008 01:53:47 +0000 (01:53 +0000)
committerPavel Sanda <sanda@lyx.org>
Sun, 21 Dec 2008 01:53:47 +0000 (01:53 +0000)
Bug http://bugzilla.lyx.org/show_bug.cgi?id=5626 .
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg146921.html .

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27939 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text3.cpp
src/insets/InsetExternal.cpp
src/insets/InsetExternal.h

index ee7865cfa8cca98c2bfb5dae309f8e06f48900c4..5a00ef8bd480a1df68bef26dd6b60c58e45245f0 100644 (file)
@@ -54,6 +54,7 @@
 
 #include "insets/InsetCollapsable.h"
 #include "insets/InsetCommand.h"
+#include "insets/InsetExternal.h"
 #include "insets/InsetFloatList.h"
 #include "insets/InsetNewline.h"
 #include "insets/InsetQuotes.h"
@@ -850,7 +851,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_INSET_INSERT: {
                cur.recordUndo();
+
+               // We have to avoid triggering InstantPreview loading
+               // before inserting into the document. See bug #5626.
+               bool loaded = bv->buffer().isFullyLoaded();
+               bv->buffer().setFullyLoaded(false);
                Inset * inset = createInset(bv->buffer(), cmd);
+               bv->buffer().setFullyLoaded(loaded);
+
                if (inset) {
                        // FIXME (Abdel 01/02/2006):
                        // What follows would be a partial fix for bug 2154:
@@ -878,7 +886,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                cutSelection(cur, true, false);
                        cur.insert(inset);
                        cur.posForward();
+
+                       // trigger InstantPreview now
+                       if (inset->lyxCode() == EXTERNAL_CODE) {
+                               InsetExternal & ins = static_cast<InsetExternal &>(*inset);
+                               ins.updatePreview();
+                       }
                }
+
                break;
        }
 
index 1fafc96a6e26500e353513de873a7ebf9f63969b..a3a739222f1a3f21821ced19ab93c0854c4bb9a0 100644 (file)
@@ -539,6 +539,12 @@ InsetExternalParams const & InsetExternal::params() const
 }
 
 
+void InsetExternal::updatePreview()
+{
+       setParams(params_);
+}
+
+
 void InsetExternal::setParams(InsetExternalParams const & p)
 {
        params_ = p;
index a9f8adbe5347b2ce7cef040a3c72d65d9fd3a636..962ac48de16f6e0376996f54015e43b9ff35bd4c 100644 (file)
@@ -107,6 +107,8 @@ public:
        InsetExternalParams const & params() const;
        ///
        void setParams(InsetExternalParams const &);
+       /// Update not loaded previews
+       void updatePreview();
        /// \returns the number of rows (\n's) of generated code.
        int latex(odocstream &, OutputParams const &) const;
        ///