mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
fix (potential?) memory leaks; cosmetics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2403 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cc3955aa12
commit
84b01259ef
@ -1,3 +1,8 @@
|
||||
2001-08-01 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* math_cursor.C:
|
||||
formulamacro.C: fix memory leaks
|
||||
|
||||
2001-07-25 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* formulabase.C: re-enable 'space enlargement' feature
|
||||
|
@ -50,10 +50,6 @@ extern char const * latex_mathenv[];
|
||||
extern MathCursor * mathcursor;
|
||||
|
||||
|
||||
// quite a hack i know. Should be done with return values...
|
||||
int number_of_newlines = 0;
|
||||
|
||||
|
||||
InsetFormula::InsetFormula()
|
||||
: InsetFormulaBase(new MathMatrixInset)
|
||||
{}
|
||||
@ -316,6 +312,7 @@ MathMatrixInset * InsetFormula::par() const
|
||||
return static_cast<MathMatrixInset *>(par_);
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::par(MathInset * p)
|
||||
{
|
||||
delete par_;
|
||||
|
@ -96,6 +96,7 @@ int InsetFormulaMacro::docBook(ostream & os) const
|
||||
void InsetFormulaMacro::read(LyXLex & lex)
|
||||
{
|
||||
// Awful hack...
|
||||
delete par_;
|
||||
par_ = mathed_parse(lex);
|
||||
MathMacroTable::insertTemplate(tmacro());
|
||||
par_->metrics(LM_ST_TEXT);
|
||||
|
@ -132,6 +132,11 @@ MathCursor::MathCursor(InsetFormulaBase * formula)
|
||||
}
|
||||
|
||||
|
||||
MathCursor::~MathCursor()
|
||||
{
|
||||
delete imacro_;
|
||||
}
|
||||
|
||||
void MathCursor::push(MathInset * par, bool first)
|
||||
{
|
||||
MathCursorPos p;
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
///
|
||||
explicit MathCursor(InsetFormulaBase *);
|
||||
///
|
||||
~MathCursor();
|
||||
///
|
||||
void insert(char, MathTextCodes t = LM_TC_MIN);
|
||||
///
|
||||
void insert(MathInset *);
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "math_fracinset.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
MathArray mathed_parse_cell(string const &);
|
||||
|
||||
@ -28,20 +27,8 @@ void MathMacroTable::dump()
|
||||
table_type::const_iterator it;
|
||||
for (it = macro_table.begin(); it != macro_table.end(); ++it)
|
||||
lyxerr << it->first << " [" << it->second->nargs() << "] : "
|
||||
<< it->second << endl;
|
||||
lyxerr << "------------------------------------------" << endl;;
|
||||
}
|
||||
|
||||
|
||||
void MathMacroTable::updateTemplate(MathMacroTemplate * par)
|
||||
{
|
||||
table_type::iterator pos = macro_table.find(par->name());
|
||||
|
||||
if (pos == macro_table.end())
|
||||
lyxerr << "MathMacroTable::updateTemplate: no template with name '"
|
||||
<< par->name() << "' available." << endl;
|
||||
else
|
||||
pos->second = par;
|
||||
<< it->second << "\n";
|
||||
lyxerr << "------------------------------------------\n";
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +46,7 @@ MathMacroTemplate & MathMacroTable::provideTemplate(string const & name)
|
||||
|
||||
if (pos == macro_table.end()) {
|
||||
lyxerr << "MathMacroTable::provideTemplate: no template with name '"
|
||||
<< name << "' available." << endl;
|
||||
<< name << "' available.\n";
|
||||
}
|
||||
|
||||
return *pos->second;
|
||||
@ -72,6 +59,9 @@ void MathMacroTable::createTemplate
|
||||
MathMacroTemplate * t = new MathMacroTemplate(name, na);
|
||||
t->cell(0) = mathed_parse_cell(text);
|
||||
insertTemplate(t);
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning who frees this?
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +86,7 @@ void MathMacroTable::builtinMacros()
|
||||
return;
|
||||
|
||||
built = true;
|
||||
//lyxerr[Debug::MATHED] << "Building macros" << endl;
|
||||
//lyxerr[Debug::MATHED] << "Building macros\n";
|
||||
|
||||
createTemplate("emptyset", 0, "\\not0");
|
||||
createTemplate("ge", 0, "\\geq");
|
||||
|
@ -81,7 +81,7 @@ char const * latex_special_chars = "#$%&_{}";
|
||||
|
||||
namespace {
|
||||
|
||||
void mathed_parse(MathArray & array, unsigned flags);
|
||||
void mathed_parse_into(MathArray & array, unsigned flags);
|
||||
|
||||
unsigned char getuchar(std::istream * is)
|
||||
{
|
||||
@ -399,8 +399,8 @@ void mathed_parse_lines(MathInset * inset, int col, bool numbered, bool outmost)
|
||||
// reading a row
|
||||
int idx = p->nargs() - p->ncols();
|
||||
for (int i = 0; i < col - 1; ++i, ++idx)
|
||||
mathed_parse(p->cell(idx), FLAG_AMPERSAND);
|
||||
mathed_parse(p->cell(idx), FLAG_NEWLINE | FLAG_END);
|
||||
mathed_parse_into(p->cell(idx), FLAG_AMPERSAND);
|
||||
mathed_parse_into(p->cell(idx), FLAG_NEWLINE | FLAG_END);
|
||||
|
||||
if (outmost) {
|
||||
MathMatrixInset * m = static_cast<MathMatrixInset *>(p);
|
||||
@ -433,7 +433,7 @@ MathInset * mathed_parse()
|
||||
string arg = lexArg('[');
|
||||
int narg = arg.empty() ? 0 : atoi(arg.c_str());
|
||||
p = new MathMacroTemplate(name, narg);
|
||||
mathed_parse(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST);
|
||||
mathed_parse_into(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST);
|
||||
//lyxerr[Debug::MATHED] << "LM_TK_NEWCOMMAND: name: "
|
||||
// << name << " nargs: " << narg << "\n";
|
||||
break;
|
||||
@ -454,7 +454,7 @@ MathInset * mathed_parse()
|
||||
case LM_OT_SIMPLE: {
|
||||
curr_num = latex_mathenv[i].numbered;
|
||||
curr_label = string();
|
||||
mathed_parse(m->cell(0), 0);
|
||||
mathed_parse_into(m->cell(0), 0);
|
||||
m->numbered(0, curr_num);
|
||||
m->label(0, curr_label);
|
||||
break;
|
||||
@ -463,7 +463,7 @@ MathInset * mathed_parse()
|
||||
case LM_OT_EQUATION: {
|
||||
curr_num = latex_mathenv[i].numbered;
|
||||
curr_label = string();
|
||||
mathed_parse(m->cell(0), FLAG_END);
|
||||
mathed_parse_into(m->cell(0), FLAG_END);
|
||||
m->numbered(0, curr_num);
|
||||
m->label(0, curr_label);
|
||||
break;
|
||||
@ -508,13 +508,13 @@ MathInset * mathed_parse()
|
||||
void handle_frac(MathArray & array, string const & name)
|
||||
{
|
||||
MathFracInset * p = new MathFracInset(name);
|
||||
mathed_parse(p->cell(0), FLAG_ITEM);
|
||||
mathed_parse(p->cell(1), FLAG_ITEM);
|
||||
mathed_parse_into(p->cell(0), FLAG_ITEM);
|
||||
mathed_parse_into(p->cell(1), FLAG_ITEM);
|
||||
array.push_back(p);
|
||||
}
|
||||
|
||||
|
||||
void mathed_parse(MathArray & array, unsigned flags)
|
||||
void mathed_parse_into(MathArray & array, unsigned flags)
|
||||
{
|
||||
static int plevel = -1;
|
||||
|
||||
@ -609,12 +609,12 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
break;
|
||||
|
||||
case '^':
|
||||
mathed_parse(
|
||||
mathed_parse_into(
|
||||
lastScriptInset(array, true, false, limits)->cell(0), FLAG_ITEM);
|
||||
break;
|
||||
|
||||
case '_':
|
||||
mathed_parse(
|
||||
mathed_parse_into(
|
||||
lastScriptInset(array, false, true, limits)->cell(1), FLAG_ITEM);
|
||||
break;
|
||||
|
||||
@ -683,12 +683,12 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
unsigned char c = getuchar(yyis);
|
||||
if (c == '[') {
|
||||
array.push_back(new MathRootInset);
|
||||
mathed_parse(array.back_inset()->cell(0), FLAG_BRACK_END);
|
||||
mathed_parse(array.back_inset()->cell(1), FLAG_ITEM);
|
||||
mathed_parse_into(array.back_inset()->cell(0), FLAG_BRACK_END);
|
||||
mathed_parse_into(array.back_inset()->cell(1), FLAG_ITEM);
|
||||
} else {
|
||||
yyis->putback(c);
|
||||
array.push_back(new MathSqrtInset);
|
||||
mathed_parse(array.back_inset()->cell(0), FLAG_ITEM);
|
||||
mathed_parse_into(array.back_inset()->cell(0), FLAG_ITEM);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -702,7 +702,7 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
ld = yylval.i;
|
||||
|
||||
MathArray ar;
|
||||
mathed_parse(ar, FLAG_RIGHT);
|
||||
mathed_parse_into(ar, FLAG_RIGHT);
|
||||
|
||||
int rd = yylex();
|
||||
if (rd == LM_TK_SYM)
|
||||
@ -736,7 +736,7 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
//MathArray tmp = array;
|
||||
//MathSizeInset * p = new MathSizeInset(MathStyles(yylval.l->id));
|
||||
//array.push_back(p);
|
||||
//mathed_parse(p->cell(0), FLAG_BRACE_FONT);
|
||||
//mathed_parse_into(p->cell(0), FLAG_BRACE_FONT);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -744,7 +744,7 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
case LM_TK_DECORATION:
|
||||
{
|
||||
MathDecorationInset * p = new MathDecorationInset(yylval.l);
|
||||
mathed_parse(p->cell(0), FLAG_ITEM);
|
||||
mathed_parse_into(p->cell(0), FLAG_ITEM);
|
||||
array.push_back(p);
|
||||
break;
|
||||
}
|
||||
@ -761,7 +761,7 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
if (MathMacroTable::hasTemplate(yytext)) {
|
||||
MathMacro * m = MathMacroTable::cloneTemplate(yytext);
|
||||
for (int i = 0; i < m->nargs(); ++i)
|
||||
mathed_parse(m->cell(i), FLAG_ITEM);
|
||||
mathed_parse_into(m->cell(i), FLAG_ITEM);
|
||||
array.push_back(m);
|
||||
m->metrics(LM_ST_TEXT);
|
||||
} else
|
||||
@ -838,7 +838,7 @@ MathArray mathed_parse_cell(string const & str)
|
||||
yyis = &is;
|
||||
yylineno = 0;
|
||||
MathArray ar;
|
||||
mathed_parse(ar, 0);
|
||||
mathed_parse_into(ar, 0);
|
||||
return ar;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user