mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
add parOwner to Inset, optimize LyXText::workWidth, fix memory corruption with lots of floats (Ben)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3195 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e52ac5df2b
commit
b00e1315fe
@ -1,3 +1,17 @@
|
||||
2001-12-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* text.C (workWidth): use Inset::parOwner to find out where the
|
||||
inset has been inserted. This is a huge performance gain for large
|
||||
documents with lots of insets. If Inset::parOwner is not set, fall
|
||||
back on the brute force method
|
||||
|
||||
* paragraph_pimpl.C (insertInset):
|
||||
* paragraph.C (Paragraph):
|
||||
(cutIntoMinibuffer): set parOwner of insets when
|
||||
inserting/removing them
|
||||
|
||||
* lyxtext.h: add short comment on deleteEmptyParagraphMechanism
|
||||
|
||||
2001-12-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* tabular-old.C (getTokenValue):
|
||||
|
@ -1,5 +1,13 @@
|
||||
2001-12-11 Ben Stanley <bds02@uow.edu.au>
|
||||
|
||||
* Menubar_pimpl.C: Fixed a crashing bug when document has more
|
||||
than 80 floats and using xforms 0.88
|
||||
|
||||
2001-12-11 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* xforms_helpers.C: include lyxlength.h here
|
||||
* xforms_helpers.h: ... but not here
|
||||
|
||||
* FormTabular.C: use LyXLength instead of string wherever
|
||||
necessary; whitespace changes.
|
||||
|
||||
|
@ -337,10 +337,21 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
|
||||
if (cit->first == "TOC") continue;
|
||||
|
||||
// All the rest is for floats
|
||||
int menu2 = get_new_submenu(smn, win);
|
||||
int menu_first_sub = get_new_submenu(smn, win);
|
||||
int menu_current = menu_first_sub;
|
||||
Buffer::SingleList::const_iterator ccit = cit->second.begin();
|
||||
Buffer::SingleList::const_iterator eend = cit->second.end();
|
||||
size_type count = 0;
|
||||
for (; ccit != eend; ++ccit) {
|
||||
++count;
|
||||
if (count > max_number_of_items) {
|
||||
int menu_tmp = get_new_submenu(smn, win);
|
||||
string label = _("More");
|
||||
label += "...%m";
|
||||
fl_addtopup(menu_current, label.c_str(), menu_tmp);
|
||||
count = 1;
|
||||
menu_current = menu_tmp;
|
||||
}
|
||||
int const action =
|
||||
lyxaction
|
||||
.getPseudoAction(LFUN_GOTO_PARAGRAPH,
|
||||
@ -348,10 +359,10 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
|
||||
string label = fixlabel(ccit->str);
|
||||
label = limit_string_length(label);
|
||||
label += "%x" + tostr(action + action_offset);
|
||||
fl_addtopup(menu2, label.c_str());
|
||||
fl_addtopup(menu_current, label.c_str());
|
||||
}
|
||||
string const m = floatList[cit->first]->second.name() + "%m";
|
||||
fl_addtopup(menu, m.c_str(), menu2);
|
||||
fl_addtopup(menu, m.c_str(), menu_first_sub);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "support/lstrings.h" // frontStrip, strip
|
||||
#include "gettext.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "lyxlength.h"
|
||||
|
||||
using std::ofstream;
|
||||
using std::pair;
|
||||
|
@ -12,11 +12,12 @@
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#include "Color.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyxlength.h"
|
||||
#include "LString.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LyXLength;
|
||||
|
||||
/// Extract shortcut from <ident>|<shortcut> string
|
||||
char const * flyx_shortcut_extract(char const * sc);
|
||||
/// Shortcut for flyx_shortcut_extract
|
||||
@ -32,7 +33,7 @@ void setEnabled(FL_OBJECT *, bool enable);
|
||||
|
||||
/// Take a string and add breaks so that it fits into a desired label width, w
|
||||
string formatted(string const &label, int w,
|
||||
int=FL_NORMAL_SIZE, int=FL_NORMAL_STYLE);
|
||||
int = FL_NORMAL_SIZE, int = FL_NORMAL_STYLE);
|
||||
|
||||
/// Given an fl_choice, create a vector of its entries
|
||||
std::vector<string> const getVectorFromChoice(FL_OBJECT *);
|
||||
|
@ -1,3 +1,8 @@
|
||||
2001-12-11 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* inset.h: add par_owner_ member variable and parOwner
|
||||
setter/accessor.
|
||||
|
||||
2001-12-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* insettabular.C (everywhere): adapt because widths are now real
|
||||
|
@ -35,7 +35,8 @@ unsigned int Inset::inset_id = 0;
|
||||
|
||||
Inset::Inset()
|
||||
: top_x(0), topx_set(false), top_baseline(0), scx(0),
|
||||
id_(inset_id++), owner_(0), background_color_(LColor::inherit)
|
||||
id_(inset_id++), owner_(0), par_owner_(0),
|
||||
background_color_(LColor::inherit)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -226,6 +226,10 @@ public:
|
||||
///
|
||||
Inset * owner() const { return owner_; }
|
||||
///
|
||||
void parOwner(Paragraph * par) { par_owner_ = par; }
|
||||
///
|
||||
Paragraph * parOwner() const {return par_owner_; }
|
||||
///
|
||||
void setBackgroundColor(LColor::color);
|
||||
///
|
||||
LColor::color backgroundColor() const;
|
||||
@ -318,6 +322,8 @@ protected:
|
||||
private:
|
||||
///
|
||||
Inset * owner_;
|
||||
/// the paragraph in which this inset has been inserted
|
||||
Paragraph * par_owner_;
|
||||
///
|
||||
string name_;
|
||||
///
|
||||
|
@ -612,7 +612,7 @@ private:
|
||||
LyXCursor & cur,
|
||||
LyXCursor const & where) const;
|
||||
|
||||
///
|
||||
/// delete double space or empty paragraphs around old_cursor
|
||||
void deleteEmptyParagraphMechanism(BufferView *,
|
||||
LyXCursor const & old_cursor) const;
|
||||
|
||||
|
@ -89,7 +89,7 @@ Paragraph::Paragraph()
|
||||
}
|
||||
|
||||
|
||||
// This construktor inserts the new paragraph in a list.
|
||||
// This constructor inserts the new paragraph in a list.
|
||||
Paragraph::Paragraph(Paragraph * par)
|
||||
: layout(0), pimpl_(new Paragraph::Pimpl(this))
|
||||
{
|
||||
@ -140,6 +140,8 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
|
||||
it != insetlist.end(); ++it)
|
||||
{
|
||||
it->inset = it->inset->clone(*current_view->buffer(), same_ids);
|
||||
// tell the new inset who is the boss now
|
||||
it->inset->parOwner(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,6 +440,8 @@ void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
|
||||
search_elem, Pimpl::matchIT());
|
||||
if (it != insetlist.end() && it->pos == pos)
|
||||
it->inset = 0;
|
||||
// the inset is not in a paragraph anymore
|
||||
minibuffer_inset->parOwner(0);
|
||||
} else {
|
||||
minibuffer_inset = 0;
|
||||
minibuffer_char = ' ';
|
||||
@ -1193,7 +1197,7 @@ int Paragraph::autoDeleteInsets()
|
||||
while (index < insetlist.size()) {
|
||||
if (insetlist[index].inset && insetlist[index].inset->autoDelete()) {
|
||||
erase(insetlist[index].pos);
|
||||
// Erase() calls to insetlist.erase(&insetlist[index])
|
||||
// erase() calls to insetlist.erase(&insetlist[index])
|
||||
// so index shouldn't be increased.
|
||||
++count;
|
||||
} else
|
||||
|
@ -258,7 +258,7 @@ public:
|
||||
/// Returns the height of the highest font in range
|
||||
LyXFont::FONT_SIZE highestFontInRange(lyx::pos_type startpos,
|
||||
lyx::pos_type endpos,
|
||||
LyXFont::FONT_SIZE const def_size) const;
|
||||
LyXFont::FONT_SIZE const def_size) const;
|
||||
///
|
||||
void insertChar(lyx::pos_type pos, value_type c);
|
||||
///
|
||||
|
@ -150,6 +150,7 @@ void Paragraph::Pimpl::insertInset(pos_type pos,
|
||||
"there is an inset in position: " << pos << std::endl;
|
||||
} else {
|
||||
owner_->insetlist.insert(it, InsetTable(pos, inset));
|
||||
inset->parOwner(owner_);
|
||||
}
|
||||
|
||||
if (inset_owner)
|
||||
|
25
src/text.C
25
src/text.C
@ -69,17 +69,26 @@ int LyXText::workWidth(BufferView * bview) const
|
||||
int LyXText::workWidth(BufferView * bview, Inset * inset) const
|
||||
{
|
||||
Paragraph * par = 0;
|
||||
pos_type pos = 0;
|
||||
pos_type pos = -1;
|
||||
|
||||
Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin();
|
||||
Buffer::inset_iterator end = bview->buffer()->inset_iterator_end();
|
||||
for ( ; it != end; ++it) {
|
||||
if (*it == inset) {
|
||||
par = it.getPar();
|
||||
pos = it.getPos();
|
||||
break;
|
||||
par = inset->parOwner();
|
||||
if (par)
|
||||
pos = par->getPositionOfInset(inset);
|
||||
|
||||
if (!par || pos == -1) {
|
||||
lyxerr << "LyXText::workWidth: something is wrong,"
|
||||
" fall back to the brute force method" << endl;
|
||||
Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin();
|
||||
Buffer::inset_iterator end = bview->buffer()->inset_iterator_end();
|
||||
for ( ; it != end; ++it) {
|
||||
if (*it == inset) {
|
||||
par = it.getPar();
|
||||
pos = it.getPos();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!par) {
|
||||
return workWidth(bview);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ bool textUndo(BufferView * bv)
|
||||
if (first) {
|
||||
bv->buffer()->redostack.push(
|
||||
createUndo(bv, undo->kind, first,
|
||||
bv->buffer()->getParFromID(undo->number_of_behind_par)));
|
||||
bv->buffer()->getParFromID(undo->number_of_behind_par)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -119,8 +119,10 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
|
||||
while (tmppar5 && tmppar5 != behind) {
|
||||
tmppar = tmppar5;
|
||||
tmppar5 = tmppar5->next();
|
||||
// a memory optimization for edit: Only layout information
|
||||
// is stored in the undo. So restore the text informations.
|
||||
// a memory optimization for edit:
|
||||
// Only layout information
|
||||
// is stored in the undo. So restore
|
||||
// the text informations.
|
||||
if (undo->kind == Undo::EDIT) {
|
||||
tmppar2->setContentsFromPar(tmppar);
|
||||
tmppar->clearContents();
|
||||
@ -171,10 +173,11 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
|
||||
LyXFont font;
|
||||
it->update(bv, font, false);
|
||||
#ifdef THIS_DOES_NOT_WORK
|
||||
// we need this anyway as also if the undo was inside an inset
|
||||
// we have to redo the paragraph breaking
|
||||
// we need this anyway as also if the undo was
|
||||
// inside an inset we have to redo the
|
||||
// paragraph breaking
|
||||
bv->text->redoParagraphs(bv, bv->text->cursor,
|
||||
bv->text->cursor.par());
|
||||
bv->text->cursor.par());
|
||||
#endif
|
||||
} else {
|
||||
bv->text->redoParagraphs(bv, bv->text->cursor, endpar);
|
||||
|
Loading…
Reference in New Issue
Block a user