Reorganize window resizing so that no painting occurs during a resizeEvent(). This caused the crash on MacOSX because the splash image drawing was not finished before the resizeEvent() occurred because of scrollbar hiding.

* WorkArea::resizeBufferView(): delete redraw() call.

* GuiWorkArea:
  - need_resize_: new private member.
  - expose(): move pixmap painting code to new private updateScreen() method.
  - paintEvent(): resize the backing pixmap  if need be.
  - resizeEvent(): move the resizing code to paintEvent().


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16499 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-01-04 12:36:17 +00:00
parent 8f2243819a
commit 4d7795d4d2
3 changed files with 21 additions and 9 deletions

View File

@ -227,7 +227,6 @@ void WorkArea::resizeBufferView()
lyx_view_.message(_("Formatting document..."));
buffer_view_->workAreaResize(width(), height());
lyx_view_.updateLayoutChoice();
redraw();
lyx_view_.busy(false);
lyx_view_.clearMessage();
}

View File

@ -159,7 +159,7 @@ SyntheticMouseEvent::SyntheticMouseEvent()
GuiWorkArea::GuiWorkArea(int w, int h, int id, LyXView & lyx_view)
: WorkArea(id, lyx_view)
: WorkArea(id, lyx_view), need_resize_(false)
{
cursor_ = new frontend::CursorWidget();
cursor_->hide();
@ -430,12 +430,9 @@ void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
void GuiWorkArea::resizeEvent(QResizeEvent * ev)
{
stopBlinkingCursor();
screen_ = QPixmap(ev->size().width(), ev->size().height());
verticalScrollBar()->setPageStep(viewport()->height());
QAbstractScrollArea::resizeEvent(ev);
resizeBufferView();
startBlinkingCursor();
need_resize_ = true;
}
@ -500,6 +497,13 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
<< " h: " << rc.height() << endl;
*/
if (need_resize_) {
screen_ = QPixmap(viewport()->width(), viewport()->height());
resizeBufferView();
updateScreen();
need_resize_ = false;
}
QPainter pain(viewport());
pain.drawPixmap(rc, screen_, rc);
cursor_->draw(pain);
@ -507,20 +511,25 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
void GuiWorkArea::expose(int x, int y, int w, int h)
{
updateScreen();
update(x, y, w, h);
}
void GuiWorkArea::updateScreen()
{
QLPainter pain(&screen_);
if (greyed_out_) {
lyxerr[Debug::GUI] << "splash screen requested" << endl;
doGreyOut(pain);
verticalScrollBar()->hide();
update(0, 0, width(), height());
doGreyOut(pain);
return;
}
verticalScrollBar()->show();
paintText(*buffer_view_, pain);
update(x, y, w, h);
}

View File

@ -166,7 +166,11 @@ private:
///
CursorWidget * cursor_;
///
void updateScreen();
///
QPixmap screen_;
///
bool need_resize_;
};
} // namespace frontend