diff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cppindex 8b4fa23..52c8106 100644--- a/src/viewer/ircview.cpp+++ b/src/viewer/ircview.cpp@@ -147,6 +147,7 @@ IRCView::IRCView(QWidget* parent, Server* newServer) : KTextBrowser(parent), m_n //// Marker lines connect(document(), SIGNAL(contentsChange(int, int, int)), SLOT(cullMarkedLine(int, int, int)));+ connect(document(), SIGNAL(contentsChanged()), SLOT(flushAddRem())); //This assert is here because a bad build environment can cause this to fail. There is a note // in the Qt source that indicates an error should be output, but there is no such output.@@ -352,6 +353,28 @@ QDebug operator<<(QDebug dbg, QList<QTextBlock> &l) return dbg.space(); }+QDebug operator<<(QDebug dbg, const QList<IRCView::WAM> &l)+{+ dbg.space() << _S(l.count()) << endl;+ for (int i=0; i< l.count(); ++i)+ {+ const IRCView::WAM& w = l[i];+ dbg.space()+ << _S(w.where)+ << _S(w.rem)+ << _S(w.add)+ << _S(w.m)+ << _S(w.b)+ << _S(w.ncm)+ << _S(w.len)+ << _S(w.s)+ << _S(w.pos)+ << endl;+ }++ return dbg.space();+}+ class IrcViewMimeData : public QMimeData { public:@@ -433,8 +456,30 @@ QSizeF IrcViewMarkerLine::intrinsicSize(QTextDocument *doc, int posInDocument, c return QSizeF(width, 6); // FIXME this is a hardcoded value... }+void recurseAndDie(int x, const QStringList& l, char *d)+{+ if (x>0)+ {+ x--;+ recurseAndDie(x, l, l[x].toLatin1().data());+ }+ else+ qFatal("crash in cullMarkedLine for political reasons");+}+ void IRCView::cullMarkedLine(int where, int rem, int add) //slot {+ WAM w;+ w.where=where;+ w.rem=rem;+ w.add=add;+ w.m=m_markers.count();+ w.b=document()->blockCount();+ w.ncm=m_nextCullIsMarker;+ w.len=document()->firstBlock().length();+ w.s = document()->firstBlock().userState();+ w.pos = m_rememberLinePosition;+ wams << w; if (where == 0 && add == 0 && rem !=0) { if (document()->blockCount() == 1 && document()->firstBlock().length() == 1)@@ -448,14 +493,30 @@ void IRCView::cullMarkedLine(int where, int rem, int add) //slot //move the remember line up.. if the cull removed it, this will forget its position if (m_rememberLinePosition >= 0) --m_rememberLinePosition;- m_markers.takeFirst();+ if (!m_markers.isEmpty())+ m_markers.takeFirst();+ //else+ {+ QString erm;+ QDebug bg(&erm);+ bg << "marker desync, no lines yet m_nextCullIsMarker: " << wams;+ QStringList erms(erm.split('\n', QString::SkipEmptyParts));+ recurseAndDie(erms.count(), erms, 0);++ Q_ASSERT(false);+ } } int s = document()->firstBlock().userState();- m_nextCullIsMarker = (s == BlockIsMarker || s == BlockIsRemember);+ m_nextCullIsMarker = (s == BlockIsMarker || s == BlockIsRemember)? s : 0; } } }+void IRCView::flushAddRem()+{+ wams.clear();+}+ void IRCView::insertMarkerLine() //slot { //if the last line is already a marker of any kind, skip outdiff --git a/src/viewer/ircview.h b/src/viewer/ircview.hindex d5ffbdc..253543d 100644--- a/src/viewer/ircview.h+++ b/src/viewer/ircview.h@@ -110,6 +110,7 @@ class IRCView : public KTextBrowser /// QTextCharFormat object types. enum ObjectFormats { MarkerLine = QTextFormat::UserObject, RememberLine};+ struct WAM { int where, add, rem, m, b, len, s, pos; bool ncm; }; public slots: /// Inserts a marker line.@@ -157,13 +158,16 @@ class IRCView : public KTextBrowser "where" is the beginning and there was nothing added. */ void cullMarkedLine(int, int, int);+ /** reset tracking of QTextDocument::contentsChange */+ void flushAddRem(); private: //marker/remember line data- bool m_nextCullIsMarker; ///< the next time a cull occurs, it'll be a marker+ int m_nextCullIsMarker; ///< the next time a cull occurs, it'll be a marker QList<QTextBlock> m_markers; ///< what blocks are markers? int m_rememberLinePosition; ///< position of remember line in m_markers bool m_rememberLineDirtyBit; ///< the next append needs a remember line IrcViewMarkerLine markerFormatObject; ///< a QTextObjectInterface+ QList<WAM> wams; //// Other stuff public slots: