]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Fix loop when opening TOC widget in an empty document, basically by Richard Heck.
[lyx.git] / src / lyxfunc.C
index 9f32b16bbbbbd90db27f10e1cc448d2822502ffe..c61681ed4aaba67be61bca1ac284c82652fd8d21 100644 (file)
@@ -264,12 +264,13 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
                }
                // moveToPosition use par_id, and par_pit and return new par_id.
                pit_type new_pit;
+               pos_type new_pos;
                int new_id;
-               boost::tie(new_pit, new_id) = view()->moveToPosition(bm.par_pit, bm.par_id, bm.par_pos);
-               // if par_id or pit has been changed, reset par_pit and par_id
+               boost::tie(new_pit, new_pos, new_id) = view()->moveToPosition(bm.bottom_pit, bm.bottom_pos, bm.top_id, bm.top_pos);
+               // if bottom_pit, bottom_pos or top_id has been changed, update bookmark
                // see http://bugzilla.lyx.org/show_bug.cgi?id=3092
-               if (bm.par_pit != new_pit || bm.par_id != new_id)
-                       const_cast<BookmarksSection::Bookmark &>(bm).setPos(new_pit, new_id);
+               if (bm.bottom_pit != new_pit || bm.bottom_pos != new_pos || bm.top_id != new_id )
+                       const_cast<BookmarksSection::Bookmark &>(bm).updatePos(new_pit, new_pos, new_id);
        } 
 }
 
@@ -1004,8 +1005,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        }
 
                        // Push directory path.
-                       string const path = buffer->temppath();
-                       support::Path p(FileName(path));
+                       string const path(buffer->temppath());
+                       // Prevent the compiler from optimizing away p
+                       FileName pp(path);
+                       support::Path p(pp);
 
                        // there are three cases here:
                        // 1. we print to a file
@@ -1561,8 +1564,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        InsetIterator it  = inset_iterator_begin(inset);
                        InsetIterator const end = inset_iterator_end(inset);
                        for (; it != end; ++it) {
-                               if (inset_code == InsetBase::NO_CODE
-                                   || inset_code == it->lyxCode()) {
+                               if (!it->asInsetMath()
+                                   && (inset_code == InsetBase::NO_CODE
+                                   || inset_code == it->lyxCode())) {
                                        LCursor tmpcur = cur;
                                        tmpcur.pushLeft(*it);
                                        it->dispatch(tmpcur, fr);
@@ -2037,9 +2041,6 @@ void LyXFunc::doImport(string const & argument)
 
 void LyXFunc::closeBuffer()
 {
-       // save current cursor position
-       LyX::ref().session().lastFilePos().save(FileName(lyx_view_->buffer()->fileName()),
-               boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
        // goto bookmark to update bookmark pit.
        for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
                gotoBookmark(i+1, false, false);