InsetText::~InsetText()
{
- // 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;
- }
+ // NOTE
+
while (par) {
Paragraph * tmp = par->next();
delete par;
void InsetText::clear()
{
- // 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;
- }
+
// now also delete all caches this should be safe, hopefully
- for (Cache::iterator cit = cache.begin(); cit != cache.end();
- cit = cache.begin())
- {
- cache.erase((*cit).first);
- }
+ cache.clear();
while (par) {
Paragraph * tmp = par->next();
int InsetText::descent(BufferView * bv, LyXFont const &) const
{
- LyXText * t = getLyXText(bv);
+ LyXText * t = getLyXText(bv);
int y_temp = 0;
Row * row = t->getRowNearY(y_temp);
insetDescent = t->height - row->ascent_of_text() +
void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
{
- LyXText * t = getLyXText(bv);
+ LyXText * t = getLyXText(bv);
#if 0
int ww = t->width;
void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
{
- LyXText * t = getLyXText(bv);
+ LyXText * t = getLyXText(bv);
t->fullRebreak(bv);
setUpdateStatus(bv, what);
if (need_update != CURSOR || t->status != LyXText::UNCHANGED ||
void InsetText::setParagraphData(Paragraph * p)
{
- // 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;
- }
+
// now also delete all caches this should be safe, hopefully
- for (Cache::iterator cit = cache.begin(); cit != cache.end();
- cit = cache.begin())
- {
- cache.erase((*cit).first);
- }
+ cache.clear();
while (par) {
Paragraph * tmp = par->next();
LyXText * InsetText::getLyXText(BufferView const * lbv,
- bool const recursive) const
+ bool const recursive) const
{
if (!recursive && (cached_bview == lbv))
- return cached_text;
+ return cached_text.get();
// Super UGLY! (Lgb)
BufferView * bv = const_cast<BufferView *>(lbv);
Cache::iterator it = cache.find(bv);
if (it != cache.end()) {
- lyx::Assert(it->second);
+ lyx::Assert(it->second.get());
cached_text = it->second;
if (recursive && the_locking_inset) {
return the_locking_inset->getLyXText(bv);
}
- return cached_text;
+ return cached_text.get();
}
- cached_text = new LyXText(const_cast<InsetText *>(this));
+ cached_text.reset(new LyXText(const_cast<InsetText *>(this)));
cached_text->init(bv);
cache.insert(make_pair(bv, cached_text));
return the_locking_inset->getLyXText(bv);
}
}
- return cached_text;
+ return cached_text.get();
}
return;
}
- lyx::Assert(it->second);
-
- delete it->second;
+ lyx::Assert(it->second.get());
+
cache.erase(bv);
if (recursive) {
/// then remove all LyXText in text-insets
if (it == cache.end()) {
return;
}
- lyx::Assert(it->second);
+ lyx::Assert(it->second.get());
Paragraph * lpar = 0;
Paragraph * selstartpar = 0;