Jean-Marc Lasgouttes wrote:
> The following patch hopefully fixes bug 2630. I say "hopefully"
> because I cannot reproduce it myself, and valgrind is mute on the
> subject. 
> 
> I attach the document on which to reproduce it. Just try to select the
> two cells of the table.
> 
> What happens is that the selection spans several cells, but the code
> for changeDepthAllowed reads
> 
>       pit_type const beg = cur.selBegin().pit();
>       pit_type const end = cur.selEnd().pit() + 1;
>       int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
> 
>       for (pit_type pit = beg; pit != end; ++pit) {
>               if (::changeDepthAllowed(type, pars_[pit], max_depth))
>                       return true;
> 
> As you can see, havoc ensues because beg and end are taken as if they
> belonged to the same text inset. The patch just quits early in this
> situation. 
> 
> People who can reproduce it (Uwe?), please tell me whether it works.
> As.gentoo, can you apply the patch and try it out?
> 
> JMarc
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: src/text2.C
> ===================================================================
> --- src/text2.C       (revision 14657)
> +++ src/text2.C       (working copy)
> @@ -385,6 +385,10 @@
>  bool LyXText::changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const
>  {
>       BOOST_ASSERT(this == cur.text());
> +     // this happens when selecting several cells in tabular (bug 2630)
> +     if (cur.idx() != cur.anchor().idx())
> +             return false;
> +
>       pit_type const beg = cur.selBegin().pit();
>       pit_type const end = cur.selEnd().pit() + 1;
>       int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);

I get a assert of the debug STL (msvc, HEAD) when I just press a key in a new 
1x1 table:

_DEBUG_ERROR("map/set iterator not dereferencable");


here the call stack of the code without your patch:

lyx-qt4.exe!std::_Tree<std::_Tmap_traits<InsetBase const 
*,Point,std::less<InsetBase const *>,std::allocator<std::pair<InsetBase const * 
const,Point> >,0> >::const_iterator::operator*()  Line 245 + 0x17 bytes        
C++
lyx-qt4.exe!std::_Tree<std::_Tmap_traits<InsetBase const 
*,Point,std::less<InsetBase const *>,std::allocator<std::pair<InsetBase const * 
const,Point> >,0> >::const_iterator::operator->()  Line 259    C++
lyx-qt4.exe!CoordCacheBase<InsetBase>::x(const InsetBase * thing=0x02788e58)  
Line 60 + 0x28 bytes      C++
lyx-qt4.exe!InsetBase::xo()  Line 341   C++
lyx-qt4.exe!InsetTabular::resetPos(LCursor & cur={...})  Line 1250 + 0x8 bytes  
C++
lyx-qt4.exe!InsetTabular::doDispatch(LCursor & cur={...}, FuncRequest & 
cmd={...})  Line 789    C++
lyx-qt4.exe!InsetBase::dispatch(LCursor & cur={...}, FuncRequest & cmd={...})  
Line 141 + 0x1a bytes    C++
lyx-qt4.exe!LCursor::dispatch(const FuncRequest & cmd0={...})  Line 292 C++
lyx-qt4.exe!LyXFunc::dispatch(const FuncRequest & cmd={...})  Line 1588 C++
lyx-qt4.exe!LyXFunc::processKeySym(boost::shared_ptr<LyXKeySym> keysym={...}, 
key_modifier::state state=none)  Line 326 + 0x38 bytes    C++
lyx-qt4.exe!BufferView::Pimpl::workAreaKeyPress(boost::shared_ptr<LyXKeySym> 
key={...}, key_modifier::state state=none)  Line 503       C++
lyx-qt4.exe!BufferView::workAreaKeyPress(boost::shared_ptr<LyXKeySym> 
key={...}, key_modifier::state state=none)  Line 241      C++
lyx-qt4.exe!lyx::frontend::WorkArea::processKeySym(boost::shared_ptr<LyXKeySym> 
key={...}, key_modifier::state state=none)  Line 224    C++
lyx-qt4.exe!lyx::frontend::GuiWorkArea::keyPressEvent(QKeyEvent * e=0x0199e8dc) 
 Line 375       C++


When I apply your patch it crashes when I insert a new 1x1 and then press "<-" 
to move with the cursor into the table.

Peter

Reply via email to