Merge pull request #3577

17b409b qt: Fix richtext detection hang issue on very old Qt versions (Wladimir J. van der Laan)
This commit is contained in:
Wladimir J. van der Laan 2014-01-23 12:57:59 +01:00
commit 22650b7d40
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

View File

@ -361,11 +361,11 @@ bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt)
{ {
QWidget *widget = static_cast<QWidget*>(obj); QWidget *widget = static_cast<QWidget*>(obj);
QString tooltip = widget->toolTip(); QString tooltip = widget->toolTip();
if(tooltip.size() > size_threshold && !tooltip.startsWith("<qt/>") && !Qt::mightBeRichText(tooltip)) if(tooltip.size() > size_threshold && !tooltip.startsWith("<qt") && !Qt::mightBeRichText(tooltip))
{ {
// Prefix <qt/> to make sure Qt detects this as rich text // Envelop with <qt></qt> to make sure Qt detects this as rich text
// Escape the current message as HTML and replace \n by <br> // Escape the current message as HTML and replace \n by <br>
tooltip = "<qt/>" + HtmlEscape(tooltip, true); tooltip = "<qt>" + HtmlEscape(tooltip, true) + "</qt>";
widget->setToolTip(tooltip); widget->setToolTip(tooltip);
return true; return true;
} }