From d9f13a9072f5cd09c0ecb49c4b1b8238eefdf0f7 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Sun, 21 Dec 2008 01:53:47 +0000 Subject: [PATCH] Fix first insert of external material & instant preview. 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 | 15 +++++++++++++++ src/insets/InsetExternal.cpp | 6 ++++++ src/insets/InsetExternal.h | 2 ++ 3 files changed, 23 insertions(+) diff --git a/src/Text3.cpp b/src/Text3.cpp index ee7865cfa8..5a00ef8bd4 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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(*inset); + ins.updatePreview(); + } } + break; } diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 1fafc96a6e..a3a739222f 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -539,6 +539,12 @@ InsetExternalParams const & InsetExternal::params() const } +void InsetExternal::updatePreview() +{ + setParams(params_); +} + + void InsetExternal::setParams(InsetExternalParams const & p) { params_ = p; diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index a9f8adbe53..962ac48de1 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -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; ///