From 275f6172aca2d156a6ec718cef3a7ef4a339f5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 14 Jul 2005 17:30:24 +0000 Subject: [PATCH] open insets when selection is set there to avoid crashs with cold coord cache git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10188 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/cursor.C | 5 ++++- src/insets/insetbase.h | 12 ++++++++---- src/insets/insetcollapsable.C | 1 - src/insets/insetcollapsable.h | 11 +++-------- src/lyxfunc.C | 4 +--- src/mathed/math_parser.C | 2 +- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 49a986493a..bf99645346 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,9 @@ +2005-05-07 André Pönitz + + * cursor.C (setSelection): open insets when selection is set there + to avoid crashs with cold coord cache + 2005-05-07 André Pönitz * trans_mgr.C (insert): move cursor to the right after inserting diff --git a/src/cursor.C b/src/cursor.C index d77f7c25c9..8e2a117d01 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -393,7 +393,7 @@ DocIterator LCursor::selectionEnd() const void LCursor::setSelection() { selection() = true; - // a selection with no contents is not a selection + // A selection with no contents is not a selection #ifdef WITH_WARNINGS #warning doesnt look ok #endif @@ -408,6 +408,9 @@ void LCursor::setSelection(DocIterator const & where, size_t n) selection() = true; anchor_ = where; pos() += n; + // Open all collapsed insets + for (int i = depth() - 1; i >= 0; --i) + operator[](i).inset().setStatus(*this, InsetBase::Open); } diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index e414bd6b15..52ead30127 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -338,10 +338,6 @@ public: /// used to toggle insets /// is the inset open? virtual bool isOpen() const { return false; } - /// open the inset - virtual void open() {} - /// close the inset - virtual void close() {} /// should this inset be handled like a normal charater virtual bool isChar() const { return false; } /// is this equivalent to a letter? @@ -399,6 +395,14 @@ public: virtual int ascent() const { return 10; } /// pretty arbitrary virtual int descent() const { return 10; } + /// + enum CollapseStatus { + Collapsed, + Inlined, + Open + }; + /// + virtual void setStatus(LCursor &, CollapseStatus) {} protected: InsetBase(); InsetBase(InsetBase const &); diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 1a829021c0..7e371e6235 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -257,7 +257,6 @@ void InsetCollapsable::edit(LCursor & cur, bool left) //lyxerr << "InsetCollapsable: edit left/right" << endl; cur.push(*this); InsetText::edit(cur, left); - open(); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 1f747325d9..a552119eb4 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -35,12 +35,6 @@ public: /// static int const TEXT_TO_BOTTOM_OFFSET = 2; /// - enum CollapseStatus { - Collapsed, - Inlined, - Open - }; - /// InsetCollapsable(BufferParams const &, CollapseStatus status = Open); /// void read(Buffer const &, LyXLex &); @@ -86,10 +80,11 @@ public: bool allowSpellCheck() const { return true; } /// bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const; - -protected: /// void setStatus(LCursor & cur, CollapseStatus st); + +protected: + /// virtual void doDispatch(LCursor & cur, FuncRequest & cmd); /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 36ec96f45b..f052b75abf 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1510,10 +1510,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd) default: { view()->cursor().dispatch(cmd); update |= view()->cursor().result().update(); - if (!view()->cursor().result().dispatched()) { + if (!view()->cursor().result().dispatched()) update |= view()->dispatch(cmd); - } - break; } } diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 05d57e8d17..216c49df55 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -181,7 +181,7 @@ void delEmptyLastRow(MathGridInset & grid) if (!grid.cell(grid.index(row, col)).empty()) return; } - grid.delRow(row + 1); + grid.delRow(row); }