This fixes a crash in InsetTabular when moving up/down.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
? 1.diff
? 2.diff
? 3.diff
? fullredraw.diff
? par-row.diff
? qfont_loader.tar.bz2
? search.diff
? tabular-il.diff
? textcache.diff
? tmp.diff
? vspace.diff
? frontends/xforms/1.diff
? insets/1.diff
? mathed/1.diff
? mathed/cursor.diff
? support/1.diff
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.233
diff -u -p -r1.233 BufferView.C
--- BufferView.C        13 Feb 2004 11:05:20 -0000      1.233
+++ BufferView.C        20 Feb 2004 10:21:09 -0000
@@ -346,6 +346,7 @@ Language const * BufferView::getParentLa
 
 Encoding const * BufferView::getEncoding() const
 {
+       lyxerr << " BufferView::getEncoding:\n" << cursor() << std::endl;
        LyXText * t = getLyXText();
        if (!t)
                return 0;
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.511
diff -u -p -r1.511 BufferView_pimpl.C
--- BufferView_pimpl.C  16 Feb 2004 11:58:39 -0000      1.511
+++ BufferView_pimpl.C  20 Feb 2004 10:21:10 -0000
@@ -981,6 +981,15 @@ bool BufferView::Pimpl::dispatch(FuncReq
 
        switch (cmd.action) {
 
+       case LFUN_ESCAPE: {
+               if (bv_->cursor().depth() > 1) {
+                       bv_->cursor().pop();
+                       // Tell the paragraph dialog that we changed paragraph
+                       dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+               }
+               break;
+       }
+
        case LFUN_UNDO:
                if (available()) {
                        cur.message(_("Undo"));
@@ -1116,6 +1125,10 @@ bool BufferView::Pimpl::dispatch(FuncReq
 
        case LFUN_UNKNOWN_ACTION:
                cur.errorMessage(N_("Unknown function!"));
+               break;
+
+       case LFUN_CENTER:
+               bv_->center();
                break;
 
        default:
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.62
diff -u -p -r1.62 cursor.C
--- cursor.C    20 Feb 2004 08:44:09 -0000      1.62
+++ cursor.C    20 Feb 2004 10:21:11 -0000
@@ -80,6 +80,9 @@ void LCursor::reset()
 DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
 {
        lyxerr << "\nLCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
+       BOOST_ASSERT(pos() <= lastpos());
+       BOOST_ASSERT(idx() <= lastidx());
+       BOOST_ASSERT(par() <= lastpar());
        FuncRequest cmd = cmd0;
        disp_.update(true);
        disp_.val(NONE);
@@ -526,6 +529,12 @@ LCursor::row_type LCursor::crow() const
 LCursor::row_type LCursor::lastcrow() const
 {
        return paragraph().rows.size();
+}
+
+
+LCursor::idx_type LCursor::lastidx() const
+{
+       return current_ ? current().lastidx() : 0;
 }
 
 
Index: cursor.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.h,v
retrieving revision 1.37
diff -u -p -r1.37 cursor.h
--- cursor.h    16 Feb 2004 11:58:40 -0000      1.37
+++ cursor.h    20 Feb 2004 10:21:11 -0000
@@ -160,7 +160,7 @@ public:
        /// return the cell of the inset this cursor is in
        idx_type & idx() { return current().idx(); }
        /// return the last possible cell in this inset
-       idx_type lastidx() const { return current().lastidx(); }
+       idx_type lastidx() const;
        /// return the paragraph this cursor is in
        par_type par() const { return current().par(); }
        /// return the paragraph this cursor is in
Index: cursor_slice.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor_slice.C,v
retrieving revision 1.16
diff -u -p -r1.16 cursor_slice.C
--- cursor_slice.C      16 Feb 2004 11:58:40 -0000      1.16
+++ cursor_slice.C      20 Feb 2004 10:21:11 -0000
@@ -43,18 +43,21 @@ CursorSlice::CursorSlice(InsetBase * p)
 
 size_t CursorSlice::nargs() const
 {
+       BOOST_ASSERT(inset_);
        return inset_->nargs();
 }
 
 
 size_t CursorSlice::nrows() const
 {
+       BOOST_ASSERT(inset_);
        return inset_->nrows();
 }
 
 
 size_t CursorSlice::ncols() const
 {
+       BOOST_ASSERT(inset_);
        return inset_->ncols();
 }
 
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.574
diff -u -p -r1.574 lyxfunc.C
--- lyxfunc.C   20 Feb 2004 08:44:09 -0000      1.574
+++ lyxfunc.C   20 Feb 2004 10:21:11 -0000
@@ -841,15 +841,6 @@ void LyXFunc::dispatch(FuncRequest const
 
                switch (action) {
 
-               case LFUN_ESCAPE: {
-                       if (!view()->available())
-                               break;
-                       view()->cursor().pop();
-                       // Tell the paragraph dialog that we changed paragraph
-                       dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
-                       break;
-               }
-
                case LFUN_WORDFINDFORWARD:
                case LFUN_WORDFINDBACKWARD: {
                        static string last_search;
@@ -901,10 +892,6 @@ void LyXFunc::dispatch(FuncRequest const
                                        !owner->buffer()->isReadonly());
                        break;
 
-               case LFUN_CENTER: // this is center and redraw.
-                       view()->center();
-                       break;
-
                // --- Menus -----------------------------------------------
                case LFUN_MENUNEW:
                        menuNew(argument, false);
@@ -1066,11 +1053,6 @@ void LyXFunc::dispatch(FuncRequest const
 
                case LFUN_FILE_OPEN:
                        open(argument);
-                       break;
-
-               case LFUN_LAYOUT_TABULAR:
-                       if (InsetTabular * tab = view()->cursor().innerInsetTabular())
-                               tab->openLayoutDialog(view());
                        break;
 
                case LFUN_DROP_LAYOUTS_CHOICE:
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.353
diff -u -p -r1.353 paragraph.C
--- paragraph.C 12 Feb 2004 16:35:58 -0000      1.353
+++ paragraph.C 20 Feb 2004 10:21:11 -0000
@@ -328,7 +328,10 @@ InsetBase const * Paragraph::getInset(po
 LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
                                         pos_type pos) const
 {
-       BOOST_ASSERT(pos <= size());
+       if (pos > size()) {
+               lyxerr << " pos: " << pos << " size: " << size() << endl;
+               BOOST_ASSERT(pos <= size());
+       }
 
        Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
        Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.405
diff -u -p -r1.405 insettabular.C
--- insets/insettabular.C       16 Feb 2004 11:58:49 -0000      1.405
+++ insets/insettabular.C       20 Feb 2004 10:21:13 -0000
@@ -491,6 +491,8 @@ void InsetTabular::priv_dispatch(LCursor
                if (sl == cur.current())
                        if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) {
                                cur.idx() = tabular.getCellBelow(cur.idx());
+                               cur.par() = 0;
+                               cur.pos() = 0;
                                resetPos(cur);
                        }
                if (sl == cur.current())
@@ -503,6 +505,8 @@ void InsetTabular::priv_dispatch(LCursor
                if (sl == cur.current())
                        if (tabular.row_of_cell(cur.idx()) != 0) {
                                cur.idx() = tabular.getCellAbove(cur.idx());
+                               cur.par() = cur.lastpar();
+                               cur.pos() = cur.lastpos();
                                resetPos(cur);
                        }
                if (sl == cur.current())

Reply via email to