]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/screen.C
Fix Qt crash
[lyx.git] / src / frontends / screen.C
index b0b3efed918c7ec035e43bcc7b90f69c9fee6bb7..93f7064ef7503bda204930f8f543919b14e28052 100644 (file)
@@ -24,6 +24,7 @@
 #include "font_metrics.h"
 #include "language.h"
 #include "debug.h"
+#include "rowpainter.h"
 
 // Splash screen-specific stuff
 #include "lyxfont.h"
@@ -110,7 +111,7 @@ SplashScreen::SplashScreen()
 
 
 LyXScreen::LyXScreen()
-       : cursor_visible_(false), force_clear_(true), greyed_out_(false)
+       : cursor_visible_(false), force_clear_(true), greyed_out_(true)
 {
        // Start loading the pixmap as soon as possible
        if (lyxrc.show_banner) {
@@ -360,13 +361,13 @@ void LyXScreen::redraw(LyXText * text, BufferView * bv)
 {
        greyed_out_ = !text;
 
-       workarea().getPainter().start();
-
        if (greyed_out_) {
                greyOut();
                return;
        }
 
+       workarea().getPainter().start();
+
        drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text);
        expose(0, 0, workarea().workWidth(), workarea().workHeight());
 
@@ -384,6 +385,8 @@ void LyXScreen::greyOut()
        if (!greyed_out_)
                return;
 
+       workarea().getPainter().start();
+
        workarea().getPainter().fillRectangle(0, 0,
                workarea().workWidth(),
                workarea().workHeight(),
@@ -431,16 +434,23 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
 
        while (row != 0 && y < y2) {
                LyXText::text_status st = text->status();
-               text->getVisibleRow(bv, y + yo,
-                                   xo, row, y + text->first_y);
+               // we need this here as the row pointer may be illegal
+               // at a later time (Jug20020502)
+               Row * prev = row->previous();
+               RowPainter rp(*bv, *text, *row);
+               if (rp.paint(y + yo, xo, y + text->first_y))
+                       text->markChangeInDraw(bv, row, prev);
+
                internal = internal && (st != LyXText::CHANGED_IN_DRAW);
                while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
                        text->fullRebreak(bv);
                        st = LyXText::NEED_MORE_REFRESH;
                        text->setCursor(bv, text->cursor.par(), text->cursor.pos());
                        text->status(bv, st);
-                       text->getVisibleRow(bv, y + yo,
-                                           xo, row, y + text->first_y);
+                       Row * prev = row->previous();
+                       RowPainter rp(*bv, *text, *row);
+                       if (rp.paint(y + yo, xo, y + text->first_y))
+                               text->markChangeInDraw(bv, row, prev);
                }
                y += row->height();
                row = row->next();
@@ -463,7 +473,10 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
 
        if (((y + row->height()) > 0) &&
            ((y - row->height()) <= static_cast<int>(workarea().workHeight()))) {
-               text->getVisibleRow(bv, y, xo, row, y + text->first_y);
+               Row * prev = row->previous();
+               RowPainter rp(*bv, *text, *row);
+               if (rp.paint(y, xo, y + text->first_y))
+                       text->markChangeInDraw(bv, row, prev);
        }
        force_clear_ = false;
 }