From 4d7795d4d21bc040ec5913b4de7019d261e3fbcb Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 4 Jan 2007 12:36:17 +0000 Subject: [PATCH] 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 --- src/frontends/WorkArea.C | 1 - src/frontends/qt4/GuiWorkArea.C | 25 +++++++++++++++++-------- src/frontends/qt4/GuiWorkArea.h | 4 ++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index 82f5e573d8..135dd2071e 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -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(); } diff --git a/src/frontends/qt4/GuiWorkArea.C b/src/frontends/qt4/GuiWorkArea.C index 1cd9674741..65453d75d0 100644 --- a/src/frontends/qt4/GuiWorkArea.C +++ b/src/frontends/qt4/GuiWorkArea.C @@ -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); } diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 208414f3f2..c9843504bd 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -166,7 +166,11 @@ private: /// CursorWidget * cursor_; /// + void updateScreen(); + /// QPixmap screen_; + /// + bool need_resize_; }; } // namespace frontend