]> git.lyx.org Git - features.git/commitdiff
* reset current_view_ when deleting a GuiView.
authorStefan Schimanski <sts@lyx.org>
Sat, 15 Mar 2008 02:42:59 +0000 (02:42 +0000)
committerStefan Schimanski <sts@lyx.org>
Sat, 15 Mar 2008 02:42:59 +0000 (02:42 +0000)
* 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
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiView.cpp
src/mathed/InsetMathNest.cpp

index 9b6e1f6e37de14ee1c58e24761c5adf22675a535..6606ec195e7f14dfcd9e15634974bb08ac2795aa 100644 (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);
 }
 
 
index 436732856b2af83884a97abc89e538d048b85387..d9b10bac071e2d626e198b17d1cf229f5812d58a 100644 (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(); }
        ///
index ba6b33dd0c7f6c7893996710ecffbc9c1e77f21f..51964929fa237af7bb7cc163b259c3ad7ff56adf 100644 (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);
index e2a8eba2e5f7ab5aecc7666c81feb44deab70256..923a1236665f54744d8767bce9b0069672502161 100644 (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());
 }