mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +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))
|
if (!theBufferList().close(theBufferList().getBuffer(s), false))
|
||||||
return false;
|
return false;
|
||||||
// Fall through to new load. (Asger)
|
// Fall through to new load. (Asger)
|
||||||
|
buffer_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer * b = 0;
|
Buffer * b = 0;
|
||||||
|
@ -105,6 +105,8 @@ Buffer * LyXView::buffer() const
|
|||||||
|
|
||||||
void LyXView::setBuffer(Buffer * b)
|
void LyXView::setBuffer(Buffer * b)
|
||||||
{
|
{
|
||||||
|
busy(true);
|
||||||
|
|
||||||
if (work_area_->bufferView().buffer())
|
if (work_area_->bufferView().buffer())
|
||||||
disconnectBuffer();
|
disconnectBuffer();
|
||||||
|
|
||||||
@ -129,12 +131,15 @@ void LyXView::setBuffer(Buffer * b)
|
|||||||
updateLayoutChoice();
|
updateLayoutChoice();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
|
busy(false);
|
||||||
work_area_->redraw();
|
work_area_->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
|
bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
|
||||||
{
|
{
|
||||||
|
busy(true);
|
||||||
|
|
||||||
if (work_area_->bufferView().buffer())
|
if (work_area_->bufferView().buffer())
|
||||||
disconnectBuffer();
|
disconnectBuffer();
|
||||||
|
|
||||||
@ -149,6 +154,7 @@ bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
showErrorList("Parse");
|
showErrorList("Parse");
|
||||||
}
|
}
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
|
busy(false);
|
||||||
work_area_->redraw();
|
work_area_->redraw();
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
virtual void saveGeometry() = 0;
|
virtual void saveGeometry() = 0;
|
||||||
|
|
||||||
/// show busy cursor
|
/// show busy cursor
|
||||||
virtual void busy(bool) const = 0;
|
virtual void busy(bool) = 0;
|
||||||
|
|
||||||
virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 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()
|
void WorkArea::checkAndGreyOut()
|
||||||
{
|
{
|
||||||
if (greyed_out_)
|
if (greyed_out_)
|
||||||
|
@ -85,6 +85,9 @@ public:
|
|||||||
virtual void redraw();
|
virtual void redraw();
|
||||||
///
|
///
|
||||||
void checkAndGreyOut();
|
void checkAndGreyOut();
|
||||||
|
///
|
||||||
|
void stopBlinkingCursor();
|
||||||
|
void startBlinkingCursor();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// grey out (no buffer)
|
/// grey out (no buffer)
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "GuiImplementation.h"
|
|
||||||
|
|
||||||
#include "GuiView.h"
|
#include "GuiView.h"
|
||||||
|
|
||||||
|
#include "GuiImplementation.h"
|
||||||
|
#include "GuiWorkArea.h"
|
||||||
#include "QLMenubar.h"
|
#include "QLMenubar.h"
|
||||||
#include "QLToolbar.h"
|
#include "QLToolbar.h"
|
||||||
#include "QCommandBuffer.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);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
work_area_->startBlinkingCursor();
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
int posx, int posy,
|
int posx, int posy,
|
||||||
bool maximize);
|
bool maximize);
|
||||||
virtual void saveGeometry();
|
virtual void saveGeometry();
|
||||||
virtual void busy(bool) const;
|
virtual void busy(bool);
|
||||||
Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
|
Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
|
||||||
virtual void updateStatusBar();
|
virtual void updateStatusBar();
|
||||||
virtual void message(lyx::docstring const & str);
|
virtual void message(lyx::docstring const & str);
|
||||||
|
@ -898,6 +898,9 @@ void paintPar
|
|||||||
void paintText(BufferView & bv, ViewMetricsInfo const & vi,
|
void paintText(BufferView & bv, ViewMetricsInfo const & vi,
|
||||||
Painter & pain)
|
Painter & pain)
|
||||||
{
|
{
|
||||||
|
if (!bv.buffer())
|
||||||
|
return;
|
||||||
|
|
||||||
LyXText & text = bv.buffer()->text();
|
LyXText & text = bv.buffer()->text();
|
||||||
bool const select = bv.cursor().selection();
|
bool const select = bv.cursor().selection();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user