mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
This commit fixes 3 crashes when reverting a document:
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
This commit is contained in:
parent
b6a7dd3aa7
commit
128a8ef3e8
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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_)
|
||||
|
@ -85,6 +85,9 @@ public:
|
||||
virtual void redraw();
|
||||
///
|
||||
void checkAndGreyOut();
|
||||
///
|
||||
void stopBlinkingCursor();
|
||||
void startBlinkingCursor();
|
||||
|
||||
protected:
|
||||
/// grey out (no buffer)
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
#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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user