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