* reset current_view_ when deleting a GuiView.

* check for current_view_ when exiting to avoid segfaults


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23752 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2008-03-15 02:42:59 +00:00
parent 214828d961
commit 7269440c83
4 changed files with 10 additions and 5 deletions

View File

@ -296,7 +296,8 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
case LFUN_LYX_QUIT:
// quitting is triggered by the gui code
// (leaving the event loop).
current_view_->message(from_utf8(N_("Exiting.")));
if (current_view_)
current_view_->message(from_utf8(N_("Exiting.")));
if (closeAllViews())
quit();
break;
@ -421,7 +422,7 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow)
#endif
}
view->setFocus();
setCurrentView(*view);
setCurrentView(view);
}

View File

@ -96,7 +96,7 @@ public:
///
GuiView * currentView() { return current_view_; }
///
void setCurrentView(GuiView & view) { current_view_ = &view; }
void setCurrentView(GuiView * view) { current_view_ = view; }
///
virtual size_t viewCount() const { return view_ids_.size(); }
///

View File

@ -336,6 +336,10 @@ GuiView::GuiView(int id)
GuiView::~GuiView()
{
if (guiApp->currentView() == this)
guiApp->setCurrentView(0);
theLyXFunc().setLyXView(0);
delete &d;
}
@ -600,7 +604,7 @@ bool GuiView::event(QEvent * e)
setFocus();
return QMainWindow::event(e);
}
guiApp->setCurrentView(*this);
guiApp->setCurrentView(this);
if (d.current_work_area_) {
BufferView & bv = d.current_work_area_->bufferView();
connectBufferView(bv);

View File

@ -1599,7 +1599,7 @@ bool InsetMathNest::interpretString(Cursor & cur, docstring const & str)
bool InsetMathNest::script(Cursor & cur, bool up)
{
script(cur, up, docstring());
return script(cur, up, docstring());
}