prevent triggering a crash in Qt's text layouting

also simplifies code as a fun side effect.
This commit is contained in:
Aaron Seigo 2011-07-11 21:45:56 +02:00
parent f056d71baa
commit 6150c12907

View File

@ -56,10 +56,6 @@ public:
m_toolTip(parent), m_toolTip(parent),
m_document(new QTextDocument(this)) m_document(new QTextDocument(this))
{ {
//d->text->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
// QTextOption op;
// op.setWrapMode(QTextOption::WordWrap);
// m_document->setDefaultTextOption(op);
} }
void setStyleSheet(const QString &css) void setStyleSheet(const QString &css)
@ -71,18 +67,16 @@ public:
{ {
QString html; QString html;
if (!data.mainText().isEmpty()) { if (!data.mainText().isEmpty()) {
html.append("<b>" + data.mainText() + "</b>"); html.append("<div><b>" + data.mainText() + "</b></div>");
if (!data.subText().isEmpty()) {
html.append("<br>");
}
} }
html.append(data.subText()); html.append(data.subText());
m_anchor.clear(); m_anchor.clear();
m_document->clear(); m_document->clear();
data.registerResources(m_document); data.registerResources(m_document);
m_document->setHtml("<p>" + html + "</p>"); if (!html.isEmpty()) {
m_document->setHtml("<p>" + html + "</p>");
}
m_document->adjustSize(); m_document->adjustSize();
m_haloRects.clear(); m_haloRects.clear();