]> git.lyx.org Git - features.git/commitdiff
patch against infinite depth from Martin
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 27 Feb 2002 11:36:20 +0000 (11:36 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 27 Feb 2002 11:36:20 +0000 (11:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3593 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text2.C

index cc9a184b92e65e6435a7d8c9c9c34b37baa1eddd..9c1408d37587d2f598106f085a56d81b02ccef67 100644 (file)
@@ -1,3 +1,8 @@
+2002-02-26  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * text2.C (incDepth): make sure depth cannot be increased beyond
+       reasonable values.
+
 2002-02-20  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * lyxfunc.C (dispatch): act on LFUN_FORKS_SHOW and LFUN_FORKS_KILL.
index f83a41fbdec6ebd3c7149a43aa612e8193dfeeb3..d97b44c8654e015816016939734d698a6eef9b97 100644 (file)
@@ -649,19 +649,25 @@ void  LyXText::incDepth(BufferView * bview)
    
        while (true) {
                // NOTE: you can't change the depth of a bibliography entry
-               if (
-                       textclasslist.Style(bview->buffer()->params.textclass,
-                                           cursor.par()->getLayout()
-                               ).labeltype != LABEL_BIBLIO) {
+               if (textclasslist.Style(bview->buffer()->params.textclass,
+                                       cursor.par()->getLayout()).labeltype != LABEL_BIBLIO) {
                        Paragraph * prev = cursor.par()->previous();
 
-                       if (prev 
-                           && (prev->getDepth() - cursor.par()->getDepth() > 0
-                               || (prev->getDepth() == cursor.par()->getDepth()
+                       if (prev) { 
+                               const int depth_diff
+                                       = prev->getDepth() - cursor.par()->getDepth();
+                               // go deeper only if 
+                               // (1) the previous para is already
+                               //     deeper (depth_diff > 0) 
+                               // (2) the previous para is a
+                               //     list-environment at the same
+                               //     depth as this para. 
+                               if (depth_diff > 0 || (depth_diff > -1
                                    && textclasslist.Style(bview->buffer()->params.textclass,
-                                                          prev->getLayout()).isEnvironment()))) {
-                               cursor.par()->params().depth(cursor.par()->params().depth() + 1);
-                               anything_changed = true;
+                                                          prev->getLayout()).isEnvironment())) {
+                                       cursor.par()->params().depth(cursor.par()->params().depth() + 1);
+                                       anything_changed = true;
+                               }
                        }
                }
                if (cursor.par() == selection.end.par())