Author: spitz
Date: Fri Jan 20 11:44:07 2012
New Revision: 40636
URL: http://www.lyx.org/trac/changeset/40636

Log:
Fix crash due to the attempt to access paragraph() from within mathed while 
doing forward-search (bug #7992).

This should go to branch as well.

Modified:
   lyx-devel/trunk/src/frontends/qt4/GuiView.cpp

Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp       Fri Jan 20 10:31:06 
2012        (r40635)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp       Fri Jan 20 11:44:07 
2012        (r40636)
@@ -3659,9 +3659,14 @@
                                command = lyxrc.forward_search_pdf;
                        }
 
-                       int row = 
doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), 
bv->cursor().pos());
+                       DocIterator tmpcur = bv->cursor();
+                       // Leave math first
+                       while (tmpcur.inMathed())
+                               tmpcur.pop_back();
+                       int row = tmpcur.inMathed() ? 0 : 
doc_buffer->texrow().getRowFromIdPos(
+                                                               
tmpcur.paragraph().id(), tmpcur.pos());
                        LYXERR(Debug::ACTION, "Forward search: row:" << row
-                               << " id:" << bv->cursor().paragraph().id());
+                               << " id:" << tmpcur.paragraph().id());
                        if (!row || command.empty()) {
                                dr.setMessage(_("Couldn't proceed."));
                                break;

Reply via email to