]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphList.C
Minimal fix needed to give Qt a label dialog again.
[lyx.git] / src / ParagraphList.C
index 136071aa7a471375c669ba203ab72ddfbf863357..152aef2f5458d7d1a473673ab97f5afe867afcde 100644 (file)
@@ -85,6 +85,27 @@ ParagraphList::ParagraphList()
 {}
 
 
+ParagraphList::iterator
+ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
+{
+       if (it != end()) {
+               Paragraph * prev = it->previous();
+               par->next(&*it);
+               par->previous(prev);
+               prev->next(par);
+               it->previous(par);
+       } else {
+               // Find last par.
+               Paragraph * last = parlist;
+               while (last->next())
+                       last = last->next();
+               last->next(par);
+               par->previous(last);
+       }
+       return iterator(par);
+}
+
+
 void ParagraphList::clear()
 {
        while (parlist) {
@@ -100,8 +121,10 @@ void ParagraphList::erase(ParagraphList::iterator it)
        Paragraph * prev = it->previous();
        Paragraph * next = it->next();
 
-       prev->next(next);
-       next->previous(prev);
+       if (prev)
+               prev->next(next);
+       if (next)
+               next->previous(prev);
 
        delete &*it;
 }