]> git.lyx.org Git - features.git/commitdiff
small backstack fix
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 25 Oct 1999 18:52:23 +0000 (18:52 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 25 Oct 1999 18:52:23 +0000 (18:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@244 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/BackStack.h
src/BufferView.C

index 2dac56340ff0199a89462c38342de3385fe98dd1..7ebad1a9da59a1c8d93c2b8e7a29bc25e4cd697e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+1999-10-25  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/BufferView.C (restorePosition): don't do anything if the
+       backstack is empty.
+
+       * src/BackStack.h: added member empty, use this to test if there
+       is anything to pop...
+
 1999-10-25  Juergen Vigna  <jug@sad.it>
 
        * forms/form1.fd +
index f9cea923cd6d5c6d8d447695b5cfd9adffdc8ebb..fa21491cdf55c8124950bf5c99c0edb4584760ae 100644 (file)
@@ -1,15 +1,15 @@
 // -*- C++ -*-
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1997-1998 The LyX Team.
-*
-*======================================================*/
+ * ======================================================
+ 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright (C) 1997-1999 The LyX Team.
+ *
+ * ======================================================*/
 
-#ifndef _BACK_STACK_H
-#define _BACK_STACK_H
+#ifndef BACK_STACK_H
+#define BACK_STACK_H
 
 #include "LString.h"
 
@@ -30,29 +30,30 @@ public:
                /// Cursor x-position
                int x;
                /// Cursor y-position
-               int y;   
+               int y;
        };
        ///
-       BackStack(int n) : imax(n) {
-               item = new BackStackItem[imax];
-               i = 0;
-       }
+       BackStack(int n) : item(new BackStackItem[n]) , imax(n), i(0) {}
        ///
        ~BackStack() {
                delete[] item;
        }
        ///
        void push(string f, int x, int y) {
-               if (i<imax) 
+               if (i < imax) 
                        item[i++].set(f, x, y);
        }
        ///
-       string &pop(int *x, int *y) {
-               if (i>0) i--;
+       string & pop(int *x, int *y) {
+               if (i > 0) i--;
                *x = item[i].x;
                *y = item[i].y;
                return item[i].fname;
        }
+       ///
+       bool empty() const {
+               return i == 0;
+       }
 private:
        ///
        BackStackItem *item;
index 2aa07c8936de694b444f51b19d9b496e4f4db958..a9abd9ff9cc6112a7fc83383395c17a3d6888347 100644 (file)
@@ -1514,6 +1514,8 @@ void BufferView::savePosition()
 
 void BufferView::restorePosition()
 {
+       if (backstack->empty()) return;
+       
        int  x, y;
        string fname = backstack->pop(&x, &y);