]> git.lyx.org Git - features.git/commitdiff
This commit fixes 3 crashes when reverting a document:
authorAbdelrazak Younes <younes@lyx.org>
Thu, 26 Oct 2006 13:29:10 +0000 (13:29 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 26 Oct 2006 13:29:10 +0000 (13:29 +0000)
1) crash in GuiWorkArea::paintEvent(), this one is solved by by encapsulating the file loading in LyXView by busy(true)/busy(false) and by disabling/enabling the work area update in GuiView::busy().

2) crash in the cursor blinking because the cursor is timed out at the moment you click on "Revert". So the blinking cursor is now disabled/enabled in GuiView::busy().

3) crash in BufferView::setBuffer() because the current buffer was already closed folling the "revert" command.
* BufferView::loadLyXFile(): set buffer_ to 0 in case of a reload (when document is reverted)

* LyXView:
  - busy() is not const anymore (work_area_ is modified in GuiView)
  - loadLyXFile(): encapsulate the file loading with busy(true)/busy(false)
  - setBuffer(): encapsulate the buffer-switching with busy(true)/busy(false)

* GuiView::busy()
  - disable/enable workarea updates.
  - disable/enable blinking cursor.

* WorkArea: new startBlinkingCursor() and stopBlinkingCursor() methods.

* rowpainter.C:
  - paintText(): make sure there is a Buffer from which to paint.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15556 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/WorkArea.C
src/frontends/WorkArea.h
src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h
src/rowpainter.C

index ea667c43f95b50cac6bfcfa7fd202772c3fd15f6..e6f4f85bd721ca04d946af9fdfbbbda6f2d8aa12 100644 (file)
@@ -246,6 +246,7 @@ bool BufferView::loadLyXFile(string const & filename, bool tolastfiles)
                if (!theBufferList().close(theBufferList().getBuffer(s), false))
                        return false;
                // Fall through to new load. (Asger)
+               buffer_ = 0;
        }
 
        Buffer * b = 0;
index c8cc8b92ef5bb37cc276bbfab997bdedbf1b41ae..5b506ff57d528cabd2cafdd9106879c870932e2f 100644 (file)
@@ -105,6 +105,8 @@ Buffer * LyXView::buffer() const
 
 void LyXView::setBuffer(Buffer * b)
 {
+       busy(true);
+
        if (work_area_->bufferView().buffer())
                disconnectBuffer();
 
@@ -129,12 +131,15 @@ void LyXView::setBuffer(Buffer * b)
        updateLayoutChoice();
        updateWindowTitle();
        updateStatusBar();
+       busy(false);
        work_area_->redraw();
 }
 
 
 bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
 {
+       busy(true);
+
        if (work_area_->bufferView().buffer())
                disconnectBuffer();
 
@@ -149,6 +154,7 @@ bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
                showErrorList("Parse");
        }
        updateStatusBar();
+       busy(false);
        work_area_->redraw();
        return loaded;
 }
index 21dd301c81b7d6b5e84938b4450ffab4660ceb43..f9f7454c4451671221909d6a761de6f3565b13c1 100644 (file)
@@ -93,7 +93,7 @@ public:
        virtual void saveGeometry() = 0;
 
        /// show busy cursor
-       virtual void busy(bool) const = 0;
+       virtual void busy(bool) = 0;
 
        virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
 
index cf2690620fb3c37457c7be6a8bdc733d8a66471f..aa522918116b36dfbfb825dbcb7171b09509356b 100644 (file)
@@ -119,6 +119,18 @@ BufferView const & WorkArea::bufferView() const
 }
 
 
+void WorkArea::stopBlinkingCursor()
+{
+       cursor_timeout_.stop();
+}
+
+
+void WorkArea::startBlinkingCursor()
+{
+       cursor_timeout_.restart();
+}
+
+
 void WorkArea::checkAndGreyOut()
 {
        if (greyed_out_)
index 0995364f2464bba8b9f5c7367f24eaebed187ef6..6876bf7972726e78058d9e1c538f5e1e5086fd2d 100644 (file)
@@ -85,6 +85,9 @@ public:
        virtual void redraw();
        ///
        void checkAndGreyOut();
+       ///
+       void stopBlinkingCursor();
+       void startBlinkingCursor();
 
 protected:
        /// grey out (no buffer)
index 1868891cb5ea235b83f305f208b9d1c92c7f9701..f1611262deef44042de4e246d3e16c7a0e9171ae 100644 (file)
 
 #include <config.h>
 
-#include "GuiImplementation.h"
-
 #include "GuiView.h"
+
+#include "GuiImplementation.h"
+#include "GuiWorkArea.h"
 #include "QLMenubar.h"
 #include "QLToolbar.h"
 #include "QCommandBuffer.h"
@@ -288,12 +289,18 @@ void GuiView::show()
 }
 
 
-void GuiView::busy(bool yes) const
+void GuiView::busy(bool yes)
 {
-       if (yes)
+       static_cast<GuiWorkArea *>(work_area_)->setUpdatesEnabled(!yes);
+
+       if (yes) {
+               work_area_->stopBlinkingCursor();
                QApplication::setOverrideCursor(Qt::WaitCursor);
-       else
+       }
+       else {
+               work_area_->startBlinkingCursor();
                QApplication::restoreOverrideCursor();
+       }
 }
 
 
index 1eec4bb535b9ba8d599dd78495323f141882e395..f527dcec1d60f365633b8751fbf250053fe41287 100644 (file)
@@ -63,7 +63,7 @@ public:
                int posx, int posy,
                bool maximize);
        virtual void saveGeometry();
-       virtual void busy(bool) const;
+       virtual void busy(bool);
        Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
        virtual void updateStatusBar();
        virtual void message(lyx::docstring const & str);
index 40144cc4077450026a5249866f33a1a47505b801..f4fb24d1e2b806737aafc5052c10521829f7b278 100644 (file)
@@ -898,6 +898,9 @@ void paintPar
 void paintText(BufferView & bv, ViewMetricsInfo const & vi,
               Painter & pain)
 {
+       if (!bv.buffer())
+               return;
+
        LyXText & text = bv.buffer()->text();
        bool const select = bv.cursor().selection();