add some assertions.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16465 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-01-02 10:36:34 +00:00
parent 71794188c7
commit 6faf63e812
2 changed files with 13 additions and 0 deletions

View File

@ -93,6 +93,7 @@ LyXView::~LyXView()
// FIXME, there's only one WorkArea per LyXView possible for now. // FIXME, there's only one WorkArea per LyXView possible for now.
void LyXView::setWorkArea(WorkArea * work_area) void LyXView::setWorkArea(WorkArea * work_area)
{ {
BOOST_ASSERT(work_area);
work_area_ = work_area; work_area_ = work_area;
work_area_ids_.clear(); work_area_ids_.clear();
work_area_ids_.push_back(work_area_->id()); work_area_ids_.push_back(work_area_->id());
@ -101,6 +102,7 @@ void LyXView::setWorkArea(WorkArea * work_area)
Buffer * LyXView::buffer() const Buffer * LyXView::buffer() const
{ {
BOOST_ASSERT(work_area_);
return work_area_->bufferView().buffer(); return work_area_->bufferView().buffer();
} }
@ -109,6 +111,7 @@ void LyXView::setBuffer(Buffer * b)
{ {
busy(true); busy(true);
BOOST_ASSERT(work_area_);
if (work_area_->bufferView().buffer()) if (work_area_->bufferView().buffer())
disconnectBuffer(); disconnectBuffer();
@ -143,6 +146,7 @@ bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles)
{ {
busy(true); busy(true);
BOOST_ASSERT(work_area_);
if (work_area_->bufferView().buffer()) if (work_area_->bufferView().buffer())
disconnectBuffer(); disconnectBuffer();
@ -169,6 +173,7 @@ void LyXView::connectBuffer(Buffer & buf)
if (errorsConnection_.connected()) if (errorsConnection_.connected())
disconnectBuffer(); disconnectBuffer();
BOOST_ASSERT(work_area_);
bufferChangedConnection_ = bufferChangedConnection_ =
buf.changed.connect( buf.changed.connect(
boost::bind(&WorkArea::redraw, work_area_)); boost::bind(&WorkArea::redraw, work_area_));
@ -285,12 +290,14 @@ void LyXView::showReadonly(bool)
BufferView * LyXView::view() const BufferView * LyXView::view() const
{ {
BOOST_ASSERT(work_area_);
return &work_area_->bufferView(); return &work_area_->bufferView();
} }
void LyXView::updateToolbars() void LyXView::updateToolbars()
{ {
BOOST_ASSERT(work_area_);
bool const math = bool const math =
work_area_->bufferView().cursor().inMathed(); work_area_->bufferView().cursor().inMathed();
bool const table = bool const table =
@ -362,6 +369,7 @@ void LyXView::updateLayoutChoice()
current_layout = buffer()->params().getLyXTextClass().defaultLayoutName(); current_layout = buffer()->params().getLyXTextClass().defaultLayoutName();
} }
BOOST_ASSERT(work_area_);
if (work_area_->bufferView().cursor().inMathed()) if (work_area_->bufferView().cursor().inMathed())
return; return;
@ -411,6 +419,7 @@ Buffer const * const LyXView::updateInset(InsetBase const * inset) const
if (inset) { if (inset) {
buffer_ptr = work_area_->bufferView().buffer(); buffer_ptr = work_area_->bufferView().buffer();
// No FitCursor: // No FitCursor:
BOOST_ASSERT(work_area_);
work_area_->bufferView().update(Update::Force); work_area_->bufferView().update(Update::Force);
work_area_->redraw(); work_area_->redraw();
} }

View File

@ -197,6 +197,7 @@ void GuiView::close()
void GuiView::setFocus() void GuiView::setFocus()
{ {
BOOST_ASSERT(work_area_);
static_cast<GuiWorkArea *>(work_area_)->setFocus(); static_cast<GuiWorkArea *>(work_area_)->setFocus();
} }
@ -220,6 +221,7 @@ void GuiView::init()
QObject::connect(&statusbar_timer_, SIGNAL(timeout()), QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
this, SLOT(update_view_state_qt())); this, SLOT(update_view_state_qt()));
BOOST_ASSERT(work_area_);
if (!work_area_->bufferView().buffer() && !theBufferList().empty()) if (!work_area_->bufferView().buffer() && !theBufferList().empty())
setBuffer(theBufferList().first()); setBuffer(theBufferList().first());
@ -641,6 +643,7 @@ bool GuiView::event(QEvent * e)
if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) { if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym); boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
sym->set(ke); sym->set(ke);
BOOST_ASSERT(work_area_);
work_area_->processKeySym(sym, key_modifier::none); work_area_->processKeySym(sym, key_modifier::none);
e->accept(); e->accept();
return true; return true;
@ -669,6 +672,7 @@ void GuiView::show()
void GuiView::busy(bool yes) void GuiView::busy(bool yes)
{ {
BOOST_ASSERT(work_area_);
static_cast<GuiWorkArea *>(work_area_)->setUpdatesEnabled(!yes); static_cast<GuiWorkArea *>(work_area_)->setUpdatesEnabled(!yes);
if (yes) { if (yes) {