From 7269440c83735ceaac5dbe2188b9261afb417bf1 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sat, 15 Mar 2008 02:42:59 +0000 Subject: [PATCH] * 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 --- src/frontends/qt4/GuiApplication.cpp | 5 +++-- src/frontends/qt4/GuiApplication.h | 2 +- src/frontends/qt4/GuiView.cpp | 6 +++++- src/mathed/InsetMathNest.cpp | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 9b6e1f6e37..6606ec195e 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -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); } diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 436732856b..d9b10bac07 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -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(); } /// diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index ba6b33dd0c..51964929fa 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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); diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index e2a8eba2e5..923a123666 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -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()); } -- 2.39.2