From: Lars Gullik Bjønnes Date: Tue, 20 Feb 2001 16:00:22 +0000 (+0000) Subject: mathed33.diff X-Git-Tag: 1.6.10~21582 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=04a2d2ddb034ebc2eaff92997d078eee5d5805fe;p=features.git mathed33.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1577 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 19e1f78f48..c2e88945f8 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -1224,7 +1224,7 @@ InsetFormula::LocalDispatch(BufferView * bv, int action, string const & arg) static void mathedValidate(LaTeXFeatures & features, MathParInset * par) { - MathedIter it(par->GetData()); + MathedIter it(&par->GetData()); while (it.OK() && !(features.binom && features.boldsymbol)) { if (it.IsInset()) { diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index e93d5ea816..ca8d0604f5 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -195,9 +195,6 @@ void InsetFormulaMacro::Edit(BufferView * bv, int x, int y,unsigned int button) void InsetFormulaMacro::InsetUnlock(BufferView * bv) { opened = false; - MathedArray * tarray = tmacro->GetData(); - MathedIter it(tarray); - it.Clear(); tmacro->setData(par->GetData()); tmacro->setEditMode(false); InsetFormula::InsetUnlock(bv); diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index ed18539c84..e547399f65 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -452,7 +452,6 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) mt->SetStyle(LM_ST_DISPLAY); mt->SetType(type); mt->setData(p->GetData()); - p->setData(0); // BUG duda delete p; par = mt; p = mt; @@ -509,7 +508,7 @@ void MathedCursor::insertInset(MathedInset * p, int t) if (selection) { if (MathIsActive(t)) { SelCut(); - static_cast(p)->setData(&selarray); + static_cast(p)->setData(selarray); } else SelDel(); } @@ -841,11 +840,11 @@ bool MathedCursor::pullArg() if (!p) return false; - MathedArray * a = p->GetData(); + MathedArray a = p->GetData(); p->clear(); Delete(); - if (!a->empty()) { - cursor->Merge(a); + if (!a.empty()) { + cursor->Merge(&a); cursor->Adjust(); } diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 62768142e6..4ea4fb9278 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -59,14 +59,14 @@ void MathFracInset::SetStyle(short st) } -void MathFracInset::SetData(MathedArray * n, MathedArray * d) +void MathFracInset::SetData(MathedArray const & n, MathedArray const & d) { den_->setData(d); MathParInset::setData(n); } -void MathFracInset::setData(MathedArray * d) +void MathFracInset::setData(MathedArray const & d) { if (idx_ == 0) MathParInset::setData(d); @@ -85,10 +85,10 @@ void MathFracInset::GetXY(int & x, int & y) const } -MathedArray * MathFracInset::GetData() +MathedArray & MathFracInset::GetData() { if (idx_ == 0) - return &array; + return array; else return den_->GetData(); } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 071176b437..1d51a41a06 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -22,12 +22,12 @@ public: /// void Metrics(); - /** This does the same that SetData(MathedArray*) but for both + /** This does the same that SetData(MathedArray const &) but for both numerator and denominator at once. */ - void SetData(MathedArray *, MathedArray *); + void SetData(MathedArray const &, MathedArray const &); /// - void setData(MathedArray *); + void setData(MathedArray const &); /// void GetXY(int & x, int & y) const; /// @@ -35,7 +35,7 @@ public: /// bool Inside(int, int); /// - MathedArray * GetData(); + MathedArray & GetData(); /// bool setArgumentIdx(int i); // was bool Up/down(void); /// diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index d157513d0d..45b8e51255 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -70,7 +70,7 @@ MathMacro::MathMacro(MathMacro * m): for (int i = 0; i < tmplate_->getNoArgs(); ++i) { m->setArgumentIdx(i); args_[i].row = m->args_[i].row; - args_[i].array = *(m->GetData()); + args_[i].array = m->GetData(); } } @@ -134,9 +134,9 @@ int MathMacro::getMaxArgumentIdx() const } -MathedArray * MathMacro::GetData() +MathedArray & MathMacro::GetData() { - return &args_[idx_].array; + return args_[idx_].array; } @@ -167,9 +167,9 @@ void MathMacro::SetFocus(int x, int y) } -void MathMacro::setData(MathedArray * a) +void MathMacro::setData(MathedArray const & a) { - args_[idx_].array = *a; + args_[idx_].array = a; } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 24269eb366..3604468d58 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -63,11 +63,11 @@ public: /// void SetFocus(int, int); /// - MathedArray * GetData(); + MathedArray & GetData(); /// MathedRowSt * getRowSt() const; /// - void setData(MathedArray *); + void setData(MathedArray const &); /// MathedTextCodes getTCode() const; /// diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 29ecb06874..24be222fe3 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -59,8 +59,8 @@ void MathMacroTable::builtinMacros() MathMacroTemplate * m = new MathMacroTemplate("notin"); // this leaks addTemplate(m); { - MathedArray * array = new MathedArray; // this leaks - MathedIter iter(array); + MathedArray array; + MathedIter iter(&array); iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not), LM_TC_INSET); // this leaks m->setData(array); @@ -70,8 +70,8 @@ void MathMacroTable::builtinMacros() m = new MathMacroTemplate("emptyset"); // this leaks addTemplate(m); { - MathedArray * array = new MathedArray; // this leaks - MathedIter iter(array); + MathedArray array; + MathedIter iter(&array); iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not), LM_TC_INSET); // this leaks m->setData(array); @@ -80,8 +80,8 @@ void MathMacroTable::builtinMacros() m = new MathMacroTemplate("perp"); // this leaks addTemplate(m); { - MathedArray * array = new MathedArray; // this leaks - MathedIter iter(array); + MathedArray array; + MathedIter iter(&array); iter.insert(LM_bot, LM_TC_BOP); m->setData(array); } @@ -90,21 +90,21 @@ void MathMacroTable::builtinMacros() m = new MathMacroTemplate("binom", 2); addTemplate(m); { - MathedArray * array = new MathedArray; + MathedArray array; m->setData(array); - MathedIter iter(array); + MathedIter iter(&array); inset = new MathDelimInset('(', ')'); iter.insertInset(inset, LM_TC_ACTIVE_INSET); - array = new MathedArray; - MathedIter iter2(array); + array = 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); + array = MathedArray(); + MathedArray array2; + MathedIter iter3(&array); iter3.insertInset(m->getMacroPar(0), LM_TC_INSET); - MathedIter iter4(array2); + MathedIter iter4(&array2); iter4.insertInset(m->getMacroPar(1), LM_TC_INSET); frac->SetData(array, array2); } diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index eeaede5705..7f0589e666 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -45,12 +45,7 @@ MathMacroTemplate::MathMacroTemplate(string const & nm, int na, int flg): MathMacroTemplate::~MathMacroTemplate() -{ - // prevent to delete already deleted objects - for (int i = 0; i < nargs_; ++i) { - args_[i].setData(0); - } -} +{} void MathMacroTemplate::setEditMode(bool ed) @@ -154,7 +149,7 @@ void MathMacroTemplate::WriteDef(ostream & os, bool fragile) void MathMacroTemplate::setArgument(MathedArray * a, int i) { - args_[i].setData(a); + args_[i].setData(*a); } diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 3adde04632..8ba729f5cc 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -35,7 +35,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset * mt) nc_(mt->nc_), nr_(0), ws_(mt->nc_), v_align_(mt->v_align_), h_align_(mt->h_align_) { - array = *(mt->GetData()); + array = mt->GetData(); if (mt->row_ != 0) { MathedRowSt * ro = 0; MathedRowSt * mrow = mt->row_; @@ -84,10 +84,11 @@ void MathMatrixInset::SetAlign(char vv, string const & hh) // Check the number of tabs and crs -void MathMatrixInset::setData(MathedArray * a) +void MathMatrixInset::setData(MathedArray const & a) { - if (!a) return; - MathedIter it(a); + array = a; + + MathedIter it(&array); int nn = nc_ - 1; nr_ = 1; // count tabs per row @@ -115,7 +116,6 @@ void MathMatrixInset::setData(MathedArray * a) // Automatically inserts tabs around bops // DISABLED because it's very easy to insert tabs - array = *a; } diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 2645611cf6..78603f1f8c 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -30,7 +30,7 @@ public: /// void Metrics(); /// - void setData(MathedArray *); + void setData(MathedArray const &); /// void SetAlign(char, string const &); /// diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index 862f4554d0..1a0e01b25d 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -46,15 +46,9 @@ MathedInset * MathParInset::Clone() } -void MathParInset::setData(MathedArray * a) +void MathParInset::setData(MathedArray const & a) { - if (!a) { - lyxerr << "can't set Data from NULL pointer" << endl; - array = MathedArray(); - return; - } - - array = *a; + array = a; // A standard paragraph shouldn't have any tabs nor CRs. MathedIter it(&array); @@ -430,9 +424,9 @@ bool MathParInset::Permit(short f) const } -MathedArray * MathParInset::GetData() +MathedArray & MathParInset::GetData() { - return &array; + return array; } diff --git a/src/mathed/math_parinset.h b/src/mathed/math_parinset.h index ede21651d8..539f569ec6 100644 --- a/src/mathed/math_parinset.h +++ b/src/mathed/math_parinset.h @@ -31,9 +31,9 @@ public: /// virtual void UserSetSize(short); /// Data is stored in a LyXArray - virtual void setData(MathedArray *); + virtual void setData(MathedArray const &); /// - virtual MathedArray * GetData(); + virtual MathedArray & GetData(); /// Paragraph position virtual void GetXY(int &, int &) const; /// diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 3a2e90d733..b74cdd5a97 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -469,7 +469,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, macro = new MathMacroTemplate(name, na); flags = FLAG_BRACE|FLAG_BRACE_LAST; *mtx = macro; - macro->setData(array); + macro->setData(*array); break; } case LM_TK_SPECIAL: @@ -560,7 +560,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, { MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT); MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0); - p->setData(ar); + p->setData(*ar); // lyxerr << "UP[" << p->GetStyle() << "]" << endl; data.insertInset(p, LM_TC_UP); break; @@ -569,7 +569,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, { MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT); MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0); - p->setData(ar); + p->setData(*ar); data.insertInset(p, LM_TC_DOWN); break; } @@ -672,7 +672,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, MathFracInset * fc = new MathFracInset(fractype); MathedArray * num = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST); MathedArray * den = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST); - fc->SetData(num, den); + fc->SetData(*num, *den); data.insertInset(fc, LM_TC_ACTIVE_INSET); break; } @@ -685,13 +685,13 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, if (c == '[') { rt = new MathRootInset(size); rt->setArgumentIdx(0); - rt->setData(mathed_parse(FLAG_BRACK_END, 0, &rt)); + rt->setData(*mathed_parse(FLAG_BRACK_END, 0, &rt)); rt->setArgumentIdx(1); } else { yyis->putback(c); rt = new MathSqrtInset(size); } - rt->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST, 0, &rt)); + rt->setData(*mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST, 0, &rt)); data.insertInset(rt, LM_TC_ACTIVE_INSET); break; } @@ -708,7 +708,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, if (rgd == LM_TK_SYM || rgd == LM_TK_STR || rgd == LM_TK_BOP || rgd == LM_TK_SPECIAL) rgd = (rgd == LM_TK_SYM) ? yylval.l->id: yylval.i; MathDelimInset * dl = new MathDelimInset(lfd, rgd); - dl->setData(a); + dl->setData(*a); data.insertInset(dl, LM_TC_ACTIVE_INSET); // lyxerr << "RL[" << lfd << " " << rgd << "]"; break; @@ -736,7 +736,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, { MathDecorationInset * sq = new MathDecorationInset(yylval.l->id, size); - sq->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST)); + sq->setData(*mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST)); data.insertInset(sq, LM_TC_ACTIVE_INSET); break; } @@ -781,7 +781,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, else data.insertInset(p, p->getTCode()); for (int i = 0; p->setArgumentIdx(i); ++i) - p->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST)); + p->setData(*mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST)); } else { MathedInset * q = new MathFuncInset(yylval.s, LM_OT_UNDEF); @@ -802,7 +802,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, lyxerr << "[" << yylval.i << "]" << endl; --plevel; if (mt) { // && (flags & FLAG_END)) { - mt->setData(array); + mt->setData(*array); array = 0; } return array; @@ -822,7 +822,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, MathParInset * mm = new MathMatrixInset(nc, 0); mm->SetAlign(ar2[0], ar); data.insertInset(mm, LM_TC_ACTIVE_INSET); - mathed_parse(FLAG_END, mm->GetData(), &mm); + mathed_parse(FLAG_END, &mm->GetData(), &mm); } else if (is_eqn_type(yylval.i)) { if (plevel!= 0) { mathPrintError("Misplaced environment"); @@ -873,7 +873,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0, if (p) { data.insertInset(p, p->getTCode()); p->setArgumentIdx(0); - mathed_parse(FLAG_END, p->GetData(), reinterpret_cast(&p)); + mathed_parse(FLAG_END, &p->GetData(), reinterpret_cast(&p)); // for (int i = 0; p->setArgumentIdx(i); ++i) // p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST)); } else diff --git a/src/mathed/math_root.C b/src/mathed/math_root.C index d22d6c60a0..4414c57d56 100644 --- a/src/mathed/math_root.C +++ b/src/mathed/math_root.C @@ -48,7 +48,7 @@ MathedInset * MathRootInset::Clone() } -void MathRootInset::setData(MathedArray * d) +void MathRootInset::setData(MathedArray const & d) { if (idx_ == 1) MathParInset::setData(d); @@ -77,10 +77,10 @@ void MathRootInset::GetXY(int & x, int & y) const } -MathedArray * MathRootInset::GetData() +MathedArray & MathRootInset::GetData() { if (idx_ == 1) - return &array; + return array; else return uroot_->GetData(); } diff --git a/src/mathed/math_root.h b/src/mathed/math_root.h index bddb171dcf..02c856911b 100644 --- a/src/mathed/math_root.h +++ b/src/mathed/math_root.h @@ -47,11 +47,11 @@ public: /// void SetFocus(int, int); /// - void setData(MathedArray *); + void setData(MathedArray const &); /// void GetXY(int & x, int & y) const; /// - MathedArray * GetData(); + MathedArray & GetData(); /// bool setArgumentIdx(int i); /// diff --git a/src/mathed/math_xiter.C b/src/mathed/math_xiter.C index 6e449fe0bc..860dfe89a8 100644 --- a/src/mathed/math_xiter.C +++ b/src/mathed/math_xiter.C @@ -195,7 +195,7 @@ void MathedXIter::SetData(MathParInset * pp) { p_ = pp; x_ = y_ = 0; - array = p_->GetData(); + array = &p_->GetData(); ncols = p_->GetColumns(); crow_ = p_->getRowSt(); if (p_->Permit(LMPF_ALLOW_CR)) @@ -209,7 +209,7 @@ void MathedXIter::SetData(MathParInset * pp) } if (!array) { array = new MathedArray; // this leaks - p_->setData(array); + p_->setData(*array); } size_ = p_->GetStyle(); Reset();