using std::endl;
using std::min;
using std::max;
+using std::make_pair;
extern unsigned char getCurrentTextClass(Buffer *);
extern bool math_insert_greek(BufferView *, char);
old_par = 0;
last_drawn_width = -1;
frame_is_visible = false;
+ cached_bview = 0;
}
{
// delete all instances of LyXText before deleting the paragraps used
// by it.
+ cached_bview = 0;
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
delete (*cit).second;
(*cit).second = 0;
{
// delete all instances of LyXText before deleting the paragraps used
// by it.
+ cached_bview = 0;
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
delete (*cit).second;
(*cit).second = 0;
{
// delete all instances of LyXText before deleting the paragraps used
// by it.
+ cached_bview = 0;
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
delete (*cit).second;
(*cit).second = 0;
LyXText * InsetText::getLyXText(BufferView const * lbv,
bool const recursive) const
{
+ if (!recursive && (cached_bview == lbv))
+ return cached_text;
+
// Super UGLY! (Lgb)
BufferView * bv = const_cast<BufferView *>(lbv);
- if ((cache.find(bv) != cache.end()) && cache[bv]) {
- if (recursive && the_locking_inset)
+ cached_bview = bv;
+ Cache::iterator it = cache.find(bv);
+
+ if (it != cache.end()) {
+ lyx::Assert(it->second);
+
+ cached_text = it->second;
+ if (recursive && the_locking_inset) {
return the_locking_inset->getLyXText(bv);
- return cache[bv];
+ }
+ return cached_text;
}
- LyXText * lt = new LyXText(const_cast<InsetText *>(this));
- lt->init(bv);
- cache[bv] = lt;
+ cached_text = new LyXText(const_cast<InsetText *>(this));
+ cached_text->init(bv);
+
+ cache.insert(make_pair(bv, cached_text));
+
if (the_locking_inset) {
- lt->setCursor(bv, inset_par, inset_pos, true, inset_boundary);
- if (recursive)
+ cached_text->setCursor(bv, inset_par, inset_pos,
+ true, inset_boundary);
+ if (recursive) {
return the_locking_inset->getLyXText(bv);
+ }
}
- return lt;
+ return cached_text;
}
void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
{
- if ((cache.find(bv) == cache.end()) || !cache[bv])
+ cached_bview = 0;
+
+ Cache::iterator it = cache.find(bv);
+
+ if (it == cache.end()) {
return;
- delete cache[bv];
+ }
+
+ lyx::Assert(it->second);
+
+ delete it->second;
cache.erase(bv);
if (recursive) {
/// then remove all LyXText in text-insets
// one endless line, resize normally not necessary
if (!force && getMaxWidth(bv, this) < 0)
return;
- if ((cache.find(bv) == cache.end()) || !cache[bv])
- return;
+ Cache::iterator it = cache.find(bv);
+ if (it == cache.end()) {
+ return;
+ }
+ lyx::Assert(it->second);
+
Paragraph * lpar = 0;
Paragraph * selstartpar = 0;
Paragraph * selendpar = 0;
// ProhibitInput(bv);
if (locked) {
- LyXText * t = getLyXText(bv);
+ LyXText * t = getLyXText(bv);
lpar = t->cursor.par();
pos = t->cursor.pos();
boundary = t->cursor.boundary();
deleteLyXText(bv, (the_locking_inset == 0) || force);
if (lpar) {
- LyXText * t = getLyXText(bv);
+ LyXText * t = getLyXText(bv);
t->selection.set(true);
/* at this point just to avoid the Delete-Empty-Paragraph