use a reference instead of a pointer in ParagraphList::iterator

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7037 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-05-24 12:13:30 +00:00
parent 297b40c725
commit 9bf624381d
7 changed files with 22 additions and 12 deletions

View File

@ -1,5 +1,13 @@
2003-05-24 Lars Gullik Bjønnes <larsbj@gullik.net>
* paragraph_funcs.C (breakParagraph): adjust
(breakParagraphConservative): adjust
* buffer.C (readParagraph): adjust
* ParagraphList.C (insert): take a reference instead of a pointer
(insert): adjust
* paragraph.[Ch] (id): new function
* bufferlist.C (newFile): adjust

View File

@ -110,8 +110,10 @@ ParagraphList & ParagraphList::operator=(ParagraphList const & rhs)
ParagraphList::iterator
ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
ParagraphList::insert(ParagraphList::iterator it, Paragraph const & p)
{
Paragraph * par = new Paragraph(p, false);
if (it != end()) {
Paragraph * prev = it->prev_par_;
par->next_par_ = &*it;
@ -136,7 +138,7 @@ ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
void ParagraphList::insert(iterator pos, iterator beg, iterator end)
{
for (; beg != end; ++beg) {
insert(pos, new Paragraph(*beg, false));
insert(pos, *beg);
}
}

View File

@ -63,7 +63,7 @@ public:
///
ParagraphList & operator=(ParagraphList const &);
///
iterator insert(iterator it, Paragraph * par);
iterator insert(iterator it, Paragraph const & par);
///
void insert(iterator pos, iterator beg, iterator end);
///

View File

@ -368,16 +368,16 @@ int Buffer::readParagraph(LyXLex & lex, string const & token,
if (token == "\\layout") {
lex.pushToken(token);
Paragraph * par = new Paragraph();
par->params().depth(depth);
Paragraph par;
par.params().depth(depth);
if (params.tracking_changes)
par->trackChanges();
par.trackChanges();
LyXFont f(LyXFont::ALL_INHERIT, params.language);
par->setFont(0, f);
par.setFont(0, f);
// FIXME: goddamn InsetTabular makes us pass a Buffer
// not BufferParams
unknown += ::readParagraph(*this, *par, lex);
unknown += ::readParagraph(*this, par, lex);
// insert after
if (pit != pars.end())

View File

@ -4,6 +4,7 @@
(clear): adjust
(setParagraphData): separate same_id cases, adjust
(appendParagraphs): adjust
(appendParagraphs): adjust
2003-05-23 André Pönitz <poenitz@gmx.net>

View File

@ -2649,8 +2649,7 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
mergeParagraph(buffer->params, paragraphs, lastbuffer);
#else
ParagraphList::iterator pit = plist.begin();
ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(),
new Paragraph(*pit, false));
ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), *pit);
++pit;
mergeParagraph(buffer->params, paragraphs, boost::prior(ins));

View File

@ -51,7 +51,7 @@ void breakParagraph(BufferParams const & bparams,
{
// create a new paragraph, and insert into the list
ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
new Paragraph);
Paragraph());
// without doing that we get a crash when typing <Return> at the
// end of a paragraph
@ -150,7 +150,7 @@ void breakParagraphConservative(BufferParams const & bparams,
{
// create a new paragraph
ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
new Paragraph);
Paragraph());
tmp->makeSameLayout(*par);
// When can pos > size()?