From: Manuel Nickschas Date: Thu, 3 Apr 2008 16:18:00 +0000 (+0000) Subject: *headdesk* Apparently QTextLayout::FormatRange() does not have an initializing ctor... X-Git-Tag: 0.2.0-alpha5~22 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=278aef059d7652b2a4e1359d72bb4028524246d4;hp=682c6e31834a863c4c78b6dfd5f830c72a6b665d *headdesk* Apparently QTextLayout::FormatRange() does not have an initializing ctor, and using uninitialized stuff can lead to _very_ strange results, including being magically resolved by touching a variable elsewhere in the program. This should now _finally_ and once-and-for-all fix font formatting issues (if it doesn't, let me know, then it's caused by something else). /me goes and sits in a corner now. --- diff --git a/src/client/client.cpp b/src/client/client.cpp index 865855ec..69ffbfc7 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -429,6 +429,8 @@ void Client::recvMessage(const Message &message) { checkForHighlight(msg); + // FIXME clean up code! (dup) + if(msg.flags() & Message::Redirected) { BufferSettings bufferSettings; bool inStatus = bufferSettings.value("UserMessagesInStatusBuffer", QVariant(true)).toBool(); @@ -438,22 +440,21 @@ void Client::recvMessage(const Message &message) { if(inStatus) { b = statusBuffer(msg.bufferInfo().networkId()); if(b) { - b->appendMsg(msg); + b->appendMsg(msg); } else if(!inQuery && !inCurrent) { // make sure the message get's shown somewhere - b = buffer(msg.bufferInfo()); - b->appendMsg(msg); + b = buffer(msg.bufferInfo()); + b->appendMsg(msg); } } if(inQuery) { b = buffer(msg.bufferInfo().bufferId()); if(b) { - b->appendMsg(msg); - } else if(!inStatus && !inCurrent) { // make sure the message get's shown somewhere - b = statusBuffer(msg.bufferInfo().networkId()); - if(!b) - b = buffer(msg.bufferInfo()); // seems like we have to create the buffer anyways... - b->appendMsg(msg); + b->appendMsg(msg); + } else if(!inStatus && !inCurrent) { // make sure the message get's shown somewhere + b = statusBuffer(msg.bufferInfo().networkId()); + if(!b) b = buffer(msg.bufferInfo()); // seems like we have to create the buffer anyways... + b->appendMsg(msg); } } @@ -461,12 +462,11 @@ void Client::recvMessage(const Message &message) { BufferId currentId = bufferModel()->currentIndex().data(NetworkModel::BufferIdRole).value(); b = buffer(currentId); if(b && currentId != msg.bufferInfo().bufferId() && !inQuery) { - b->appendMsg(msg); + b->appendMsg(msg); } else if(!inStatus && !inQuery) { // make sure the message get's shown somewhere - b = statusBuffer(msg.bufferInfo().networkId()); - if(!b) - b = buffer(msg.bufferInfo()); // seems like we have to create the buffer anyways... - b->appendMsg(msg); + b = statusBuffer(msg.bufferInfo().networkId()); + if(!b) b = buffer(msg.bufferInfo()); // seems like we have to create the buffer anyways... + b->appendMsg(msg); } } } else { diff --git a/src/qtui/chatline-old.cpp b/src/qtui/chatline-old.cpp index 2c9cb0d3..0a3cc200 100644 --- a/src/qtui/chatline-old.cpp +++ b/src/qtui/chatline-old.cpp @@ -29,8 +29,7 @@ */ ChatLineOld::ChatLineOld(Message m) { hght = 0; - //networkName = m.buffer.network(); - //bufferName = m.buffer.buffer(); + msg = m; selectionMode = None; isHighlight = false; @@ -50,9 +49,17 @@ void ChatLineOld::formatMsg(Message msg) { precomputeLine(); } +QList ChatLineOld::calcFormatRanges(const UiStyle::StyledText &fs) { + QTextLayout::FormatRange additional; + additional.start = additional.length = 0; + return calcFormatRanges(fs, additional); +} + // This function is almost obsolete, since with the new style engine, we already get a list of formats... // We don't know yet if we keep this implementation of ChatLineOld, so I won't bother making this actually nice. -QList ChatLineOld::calcFormatRanges(UiStyle::StyledText fs, QTextLayout::FormatRange additional) { +QList ChatLineOld::calcFormatRanges(const UiStyle::StyledText &_fs, + const QTextLayout::FormatRange &additional) { + UiStyle::StyledText fs = _fs; QList ranges; if(additional.length > 0) { @@ -76,6 +83,7 @@ QList ChatLineOld::calcFormatRanges(UiStyle::StyledTex } } } + foreach(QTextLayout::FormatRange f, fs.formats) { if(f.length <= 0) continue; FormatRange range; diff --git a/src/qtui/chatline-old.h b/src/qtui/chatline-old.h index ac95494b..8d286b07 100644 --- a/src/qtui/chatline-old.h +++ b/src/qtui/chatline-old.h @@ -104,7 +104,8 @@ class ChatLineOld : public QObject, public AbstractUiMsg { int selectionStart, selectionEnd; void formatMsg(Message); void precomputeLine(); - QList calcFormatRanges(UiStyle::StyledText, QTextLayout::FormatRange additional = QTextLayout::FormatRange()); + QList calcFormatRanges(const UiStyle::StyledText &); + QList calcFormatRanges(const UiStyle::StyledText &, const QTextLayout::FormatRange &additional); }; #endif diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 959cd9bd..9b49da10 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -57,6 +57,7 @@ #include "debugconsole.h" #include "global.h" +#include "qtuistyle.h" MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), @@ -441,11 +442,12 @@ void MainWin::receiveMessage(const Message &msg) { sender = sender.left(i); title += QString(" - %1").arg(sender); } - QString text = QtUi::style()->styleString(Message::mircToInternal(msg.text())).text; UiSettings uiSettings; if(uiSettings.value("DisplayPopupMessages", QVariant(true)).toBool()) { + // FIXME don't invoke style engine for this! + QString text = QtUi::style()->styleString(Message::mircToInternal(msg.text())).text; displayTrayIconMessage(title, text); } diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 79f23c67..5f0f7175 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -26,6 +26,7 @@ UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) { QTextCharFormat def; def.setForeground(QBrush("#000000")); //def.setFont(QFont("Courier", 10)); + def.font().setFixedPitch(true); def.font().setStyleHint(QFont::TypeWriter); _defaultFormats = QVector(NumFormatTypes, def); _customFormats = QVector(NumFormatTypes, QTextFormat().toCharFormat()); @@ -130,9 +131,7 @@ QString UiStyle::formatCode(FormatType ftype) const { } UiStyle::StyledText UiStyle::styleString(const QString &_s) { - QString s = _s; // we can't use call-by-value since this seems to maybe screw up Qt's implicit sharing somehow - // at least invalid formats are created if we do that - if(s.startsWith(" ")) {}; // and yet some other stupid no-op that seems to fix the font issue on some machines... -_- + QString s = _s; StyledText result; QList fmtList; fmtList.append(None); @@ -240,5 +239,3 @@ QTextCharFormat UiStyle::mergedFormat(QList formatList) { } return fmt; } - - diff --git a/version.inc b/version.inc index 78c964ac..b005cf83 100644 --- a/version.inc +++ b/version.inc @@ -5,7 +5,7 @@ quasselVersion = "0.2.0-alpha5-pre"; quasselDate = "2008-04-03"; - quasselBuild = 695; + quasselBuild = 696; //! Minimum client build number the core needs clientBuildNeeded = 642;