debug--
[quassel.git] / src / qtui / chatitem.cpp
index e255d00..b1a071b 100644 (file)
@@ -460,7 +460,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const {
     // Sometimes, setNumColumns will create a line that's too long (cf. Qt bug 238249)
     // We verify this and try setting the width again, making it shorter each time until the lengths match.
     // Dead fugly, but seems to work…
-    for(int i = line.textLength()-1; line.textLength() > num; i--) {
+    for(int i = line.textLength()-1; i >= 0 && line.textLength() > num; i--) {
       line.setNumColumns(i);
     }
     if(num != line.textLength()) {
@@ -636,9 +636,10 @@ void ContentsChatItem::showWebPreview(const Clickable &click) {
   QPointF topLeft = scenePos() + QPointF(x, y);
   QRectF urlRect = QRectF(topLeft.x(), topLeft.y(), width, height);
 
-  QString url = data(ChatLineModel::DisplayRole).toString().mid(click.start(), click.length());
-  if(!url.contains("://"))
-    url = "http://" + url;
+  QString urlstr = data(ChatLineModel::DisplayRole).toString().mid(click.start(), click.length());
+  if(!urlstr.contains("://"))
+    urlstr= "http://" + urlstr;
+  QUrl url = QUrl::fromEncoded(urlstr.toUtf8(), QUrl::TolerantMode);
   chatScene()->loadWebPreview(this, url, urlRect);
 #endif
 }