]> git.lyx.org Git - features.git/commitdiff
mathed29.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 19 Feb 2001 18:29:10 +0000 (18:29 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 19 Feb 2001 18:29:10 +0000 (18:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1560 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/array.C
src/mathed/math_iter.C
src/mathed/math_iter.h
src/mathed/math_macrotable.C
src/mathed/math_matrixinset.C

index 95a660e87223c375352a573efe6a82a50e64fbfc..b55f21381d3aed02da253ad849395689028fb2ab 100644 (file)
@@ -8,6 +8,9 @@
 
        * math_iter.[Ch]: seperate Copy() from Copy(int, int)
 
+       * math_iter.[Ch]: remove SetData
+         several files: subsequent changes
+
 2001-02-14  André Pönitz  <poenitz@htwm.de>
 
        * array.[Ch]: remove constructor and  enums ARRAY_MIN_SIZE and ARRAY_STEP
index b5217e355c348c393fe231b23efecb846e3cea1f..c520fa99ad7f422fa2fef3ebfd2c0ba299485d63 100644 (file)
@@ -24,6 +24,7 @@ MathedArray::MathedArray()
        : bf_(1, '\0'), last_(0)
 {}
 
+
 MathedArray::~MathedArray()
 {
        // deep destruction
@@ -55,8 +56,7 @@ MathedArray::MathedArray(MathedArray const & array)
 
        // deep copy
        // we'll not yet get exeption safety
-       MathedIter it;
-       it.SetData(this);
+       MathedIter it(this);
        while (it.OK()) {
                if (it.IsInset()) {
                        MathedInset * inset = it.GetInset();
index 4a467a4b579c1b5fac871f85d4f51feab7f87198..dbbbb70711fdc9d43ab81109bedc51b2bbcc0157 100644 (file)
@@ -43,11 +43,6 @@ MathedIter::MathedIter()
 {}
 
 
-void MathedIter::SetData(MathedArray * a)
-{
-       array = a; Reset();
-}
-
 
 MathedArray * MathedIter::GetData() const
 {
@@ -403,11 +398,11 @@ MathedArray * MathedIter::Copy(int pos1, int pos2)
                return 0;
        }
 
-       ipush();
-       MathedArray * t = array;
-       MathedArray * a;
-
        if (pos1 > 0 || pos2 <= array->last()) {
+               ipush();
+               MathedArray * t = array;
+               MathedArray * a;
+
                short fc = 0;
                if (pos1 > 0 && (*array)[pos1] > ' ') {
                        for (int p = pos1; p >= 0; --p) {
@@ -436,25 +431,26 @@ MathedArray * MathedIter::Copy(int pos1, int pos2)
                }
                a->last(dx);
                (*a)[dx] = '\0';
-       } else
-               a = new MathedArray(*array);
 
-       // this should be unnecessary and leak in some (most?) cases since
-       // a = new MathedArray(*array);  makes already a deep copy...
-       // I guess it'll go soon... (Andre')
+               array = a;
+               Reset();
 
-       SetData(a);
-       while (OK()) {
-               if (IsInset()) {
-                       MathedInset * inset = GetInset();
-                       inset = inset->Clone();
-                       array->raw_pointer_insert(inset, pos + 1, sizeof(inset));
+               while (OK()) {
+                       if (IsInset()) {
+                               MathedInset * inset = GetInset();
+                               inset = inset->Clone();
+                               array->raw_pointer_insert(inset, pos + 1, sizeof(inset));
+                       }
+                       Next();
                }
-               Next();
+               array = t;
+               ipop();
+
+               return a;
        }
-       array = t;
-       ipop();
-       return a;
+
+       // otherwise: full copy
+       return new MathedArray(*array);
 }
 
 
index db8487ef7057d88d69552577a8085de923c04177..c3a27a7c664d2e2240cb5d839bb41c83239babca 100644 (file)
@@ -109,8 +109,6 @@ public:
        ///
        void setNumCols(int n) { ncols = n; }
        ///
-       void SetData(MathedArray * a);
-       ///
        MathedArray * GetData() const;
        /// Copy every object 
        MathedArray * Copy();
index d8f381dbf930cc3d49b585d858bdafc0431ca332..29ecb06874a8753dc90ca6ef5608c750c95fb692 100644 (file)
@@ -49,9 +49,7 @@ void MathMacroTable::addTemplate(MathMacroTemplate * m)
 
 void MathMacroTable::builtinMacros()
 {
-       MathedIter iter;
        MathParInset * inset;// *arg;
-       MathedArray * array2;
     
        built = true;
     
@@ -60,48 +58,56 @@ void MathMacroTable::builtinMacros()
        // This macro doesn't have arguments
        MathMacroTemplate * m = new MathMacroTemplate("notin");  // this leaks
        addTemplate(m);
-       MathedArray * array = new MathedArray; // this leaks
-       iter.SetData(array);
-       iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not),
-                        LM_TC_INSET); // this leaks
-       m->setData(array);
+       {
+               MathedArray * array = new MathedArray; // this leaks
+               MathedIter iter(array);
+               iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not),
+                                LM_TC_INSET); // this leaks
+               m->setData(array);
+       }
     
        // These two are only while we are still with LyX 2.x
        m = new MathMacroTemplate("emptyset"); // this leaks
-       addTemplate(m);
-       array = new MathedArray; // this leaks
-       iter.SetData(array);
-       iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not),
-                        LM_TC_INSET); // this leaks
-       m->setData(array);
+       addTemplate(m); 
+       {
+               MathedArray * array = new MathedArray; // this leaks
+               MathedIter iter(array);
+               iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not),
+                                LM_TC_INSET); // this leaks
+               m->setData(array);
+       }
     
        m = new MathMacroTemplate("perp"); // this leaks
        addTemplate(m);
-       array = new MathedArray; // this leaks
-       iter.SetData(array);
-       iter.insert(LM_bot, LM_TC_BOP);
-       m->setData(array);
+       {
+               MathedArray * array = new MathedArray; // this leaks
+               MathedIter iter(array);
+               iter.insert(LM_bot, LM_TC_BOP);
+               m->setData(array);
+       }
 
        // binom has two arguments
        m = new MathMacroTemplate("binom", 2);
        addTemplate(m);
-       array = new MathedArray; 
-       m->setData(array);
-       iter.SetData(array);
-       inset = new MathDelimInset('(', ')');
-       iter.insertInset(inset, LM_TC_ACTIVE_INSET);
-       array = new MathedArray; 
-       iter.SetData(array);
-       MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
-       iter.insertInset(frac, LM_TC_ACTIVE_INSET);
-       inset->setData(array);
-       array = new MathedArray;
-       array2 = new MathedArray;  
-       iter.SetData(array);
-       iter.insertInset(m->getMacroPar(0), LM_TC_INSET);
-       iter.SetData(array2);
-       iter.insertInset(m->getMacroPar(1), LM_TC_INSET);
-       frac->SetData(array, array2);
+       {
+               MathedArray * array = new MathedArray; 
+               m->setData(array);
+               MathedIter iter(array);
+               inset = new MathDelimInset('(', ')');
+               iter.insertInset(inset, LM_TC_ACTIVE_INSET);
+               array = new MathedArray; 
+               MathedIter iter2(array);
+               MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
+               iter2.insertInset(frac, LM_TC_ACTIVE_INSET);
+               inset->setData(array);
+               array = new MathedArray;
+               MathedArray * array2 = new MathedArray;  
+               MathedIter iter3(array);
+               iter3.insertInset(m->getMacroPar(0), LM_TC_INSET);
+               MathedIter iter4(array2);
+               iter4.insertInset(m->getMacroPar(1), LM_TC_INSET);
+               frac->SetData(array, array2);
+       }
 
 /*
   // Cases has 1 argument
index 8a58205f2477c52e430b5c0b28d7855467fff10a..7fe259dfc3881bf448c6dff52423f60dac5320db 100644 (file)
@@ -35,8 +35,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
          nc_(mt->nc_), nr_(0), ws_(mt->nc_),
          v_align_(mt->v_align_), h_align_(mt->h_align_)
 {
-       MathedIter it;
-       it.SetData(mt->GetData());
+       MathedIter it(mt->GetData());
        array = it.Copy();
        if (mt->row_ != 0) {
                MathedRowSt * ro = 0;