1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
krepa098 2015-02-06 16:12:24 +01:00
parent f525fa83f3
commit b9dcb3bd9b
2 changed files with 6 additions and 3 deletions

View File

@ -222,12 +222,13 @@ void Text::regenerate()
if(!doc) if(!doc)
{ {
doc = DocumentCache::getInstance().pop(); doc = DocumentCache::getInstance().pop();
doc->setDefaultFont(defFont);
dirty = true; dirty = true;
} }
if(dirty) if(dirty)
{ {
doc->setDefaultFont(defFont);
if(!elide) if(!elide)
doc->setHtml(text); doc->setHtml(text);
else else
@ -238,9 +239,8 @@ void Text::regenerate()
opt.setWrapMode(elide ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere); opt.setWrapMode(elide ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
doc->setDefaultTextOption(opt); doc->setDefaultTextOption(opt);
// width & layout // width
doc->setTextWidth(width); doc->setTextWidth(width);
doc->documentLayout()->update();
// update ascent // update ascent
if(doc->firstBlock().layout()->lineCount() > 0) if(doc->firstBlock().layout()->lineCount() > 0)

View File

@ -34,7 +34,10 @@ QTextDocument* DocumentCache::pop()
void DocumentCache::push(QTextDocument *doc) void DocumentCache::push(QTextDocument *doc)
{ {
if(doc) if(doc)
{
doc->clear();
documents.push(doc); documents.push(doc);
}
} }
DocumentCache &DocumentCache::getInstance() DocumentCache &DocumentCache::getInstance()