Buffer const * oldparent = d->parent();
d->setParent(nullptr);
ReadStatus const status = loadLyXFile();
+ setBusy(false);
if (status == ReadSuccess) {
updateBuffer();
changed(true);
} else {
message(bformat(_("Could not reload document %1$s."), disp_fn));
}
- setBusy(false);
removePreviews();
updatePreviews();
errors("Parse");
<< flagsAsString(flags) << ") buffer: " << &buffer_);
// Case when no explicit update is requested.
- if (flags == Update::None)
+ if (flags == Update::None || !ready())
return;
/* FIXME We would like to avoid doing this here, since it is very
void BufferView::updateScrollbarParameters()
{
- if (height_ == 0 && width_ == 0)
+ if (!ready())
return;
// We prefer fixed size line scrolling.
{
//lyxerr << "[ cmd0 " << cmd0 << "]" << endl;
+ if (!ready())
+ return;
+
// This is only called for mouse related events including
// LFUN_FILE_OPEN generated by drag-and-drop.
FuncRequest cmd = cmd0;
void BufferView::updateMetrics(bool force)
{
- if (height_ == 0 || width_ == 0)
+ if (!ready())
return;
Text & buftext = buffer_.text();
void BufferView::draw(frontend::Painter & pain, bool paint_caret)
{
- if (height_ == 0 || width_ == 0)
+ if (!ready())
return;
LYXERR(Debug::PAINTING, (pain.isNull() ? "\t\t--- START NODRAW ---"
: "\t\t*** START DRAWING ***"));
/// the shape of the caret
frontend::CaretGeometry const & caretGeometry() const;
+ /// Returns true when metrics have been computed at least once
+ bool ready() const { return width_ > 0 && height_ > 0; }
/// Returns true when the BufferView is not ready for drawing
bool busy() const;
///
});
d->resetScreen();
- // A mouse event will happen before the first paint event,
- // so make sure that the buffer view has an up to date metrics.
- d->buffer_view_->resize(viewport()->width(), viewport()->height());
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAcceptDrops(true);
void GuiWorkArea::scheduleRedraw(bool update_metrics)
{
- if (!isVisible())
+ if (!isVisible() || view().busy())
// No need to redraw in this case.
return;
GuiWorkArea * TabWorkArea::addWorkArea(Buffer & buffer, GuiView & view)
{
+ view.setBusy(true);
GuiWorkArea * wa = new GuiWorkArea(buffer, view);
GuiWorkAreaContainer * wac = new GuiWorkAreaContainer(wa);
wa->setUpdatesEnabled(false);
updateTabTexts();
+ view.setBusy(false);
+
return wa;
}