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
This commit is contained in:
Pavel Sanda 2008-12-21 01:53:47 +00:00
parent fd6679bd34
commit d9f13a9072
3 changed files with 23 additions and 0 deletions

View 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;
}

View File

@ -539,6 +539,12 @@ InsetExternalParams const & InsetExternal::params() const
}
void InsetExternal::updatePreview()
{
setParams(params_);
}
void InsetExternal::setParams(InsetExternalParams const & p)
{
params_ = p;

View 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;
///