mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
InsetExternal: update renderer after preview status change
This fixes a crash when changing instant preview prefs while
document with previewed external inset is opened.
Fixes: #10785
(cherry picked from commit 0842e22f45
)
This commit is contained in:
parent
9235d5299e
commit
6ef5e10e66
@ -520,12 +520,18 @@ bool InsetExternal::showInsetDialog(BufferView * bv) const
|
||||
|
||||
void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
if (!isRendererValid())
|
||||
updatePreview();
|
||||
|
||||
renderer_->metrics(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
if (!isRendererValid())
|
||||
updatePreview();
|
||||
|
||||
if (renderer_->asButton())
|
||||
renderer_->setRenderState(mouse_hover_[pi.base.bv]);
|
||||
renderer_->draw(pi, x, y);
|
||||
@ -592,9 +598,22 @@ InsetExternalParams const & InsetExternal::params() const
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::updatePreview()
|
||||
bool InsetExternal::isPreviewed() const
|
||||
{
|
||||
setParams(params_);
|
||||
return (external::getTemplatePtr(params_) && !params_.filename.empty()
|
||||
&& params_.display
|
||||
&& lyxrc.display_graphics
|
||||
&& params_.preview_mode != PREVIEW_OFF
|
||||
&& (params_.preview_mode != PREVIEW_INSTANT
|
||||
|| RenderPreview::previewText()));
|
||||
}
|
||||
|
||||
|
||||
bool InsetExternal::isRendererValid() const
|
||||
{
|
||||
if (!renderer_->asButton())
|
||||
return isPreviewed();
|
||||
return !isPreviewed();
|
||||
}
|
||||
|
||||
|
||||
@ -606,12 +625,13 @@ void InsetExternal::setParams(InsetExternalParams const & p)
|
||||
// will use this.
|
||||
defaultTemplateName = params_.templatename();
|
||||
|
||||
if (!external::getTemplatePtr(params_) || params_.filename.empty()
|
||||
|| !params_.display
|
||||
|| !lyxrc.display_graphics
|
||||
|| params_.preview_mode == PREVIEW_OFF
|
||||
|| (params_.preview_mode == PREVIEW_INSTANT
|
||||
&& !RenderPreview::previewText())) {
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::updatePreview() const
|
||||
{
|
||||
if (!isPreviewed()) {
|
||||
RenderButton * button_ptr = renderer_->asButton();
|
||||
if (!button_ptr) {
|
||||
renderer_.reset(new RenderButton);
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
///
|
||||
void setParams(InsetExternalParams const &);
|
||||
/// Update not loaded previews
|
||||
void updatePreview();
|
||||
void updatePreview() const;
|
||||
/// \returns the number of rows (\n's) of generated code.
|
||||
void latex(otexstream &, OutputParams const &) const;
|
||||
///
|
||||
@ -165,11 +165,15 @@ private:
|
||||
* and the preview should be regenerated.
|
||||
*/
|
||||
void fileChanged() const;
|
||||
/// Is this inset using (instant or graphics) preview?
|
||||
bool isPreviewed() const;
|
||||
/// Do we have the right renderer (button, graphic or monitored preview)?
|
||||
bool isRendererValid() const;
|
||||
|
||||
/// The current params
|
||||
InsetExternalParams params_;
|
||||
/// The thing that actually draws the image on LyX's screen.
|
||||
boost::scoped_ptr<RenderBase> renderer_;
|
||||
mutable boost::scoped_ptr<RenderBase> renderer_;
|
||||
/// changes color of the button when mouse enters/leaves this inset
|
||||
mutable std::map<BufferView const *, bool> mouse_hover_;
|
||||
};
|
||||
|
@ -100,6 +100,9 @@ What's new
|
||||
|
||||
- Fix crash with undo and child documents (bug 10643).
|
||||
|
||||
- Fix crash when changing preview preferences while previewable
|
||||
external inset is open (bug 10785).
|
||||
|
||||
- Remove duplicate entries from the Symbols dialog (bug 10644).
|
||||
|
||||
- Always show the float type in the float inset label (bug 10618).
|
||||
|
Loading…
Reference in New Issue
Block a user