From f109f5b8a9c7e6939dfd6c6f72a3b67548f5483c Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Wed, 16 Nov 2011 09:47:45 +0200 Subject: Fix Q_ASSERT usage in case -force-asserts is enabled Certain Q_ASSERT usages are not compiling with -force-asserts since they are checking for instance variables or other items which are not available in release mode. This fix guards the asserts to only be enabled in debug mode. Change-Id: I2ed74e3d5118608361e8c924e93d8ff0efdc8eab Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument_p.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gui/text/qtextdocument_p.cpp') diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index f4cb742d34..e70c5e63b5 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -322,7 +322,9 @@ void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout) void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op) { // ##### optimize when only appending to the fragment! +#ifndef QT_NO_DEBUG Q_ASSERT(noBlockInString(text.mid(strPos, length))); +#endif split(pos); uint x = fragments.insert_single(pos, length); @@ -478,7 +480,9 @@ void QTextDocumentPrivate::insert(int pos, const QString &str, int format) if (str.size() == 0) return; +#ifndef QT_NO_DEBUG Q_ASSERT(noBlockInString(str)); +#endif int strPos = text.length(); text.append(str); @@ -496,7 +500,9 @@ int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand:: Q_ASSERT(blocks.size(b) > length); Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length); +#ifndef QT_NO_DEBUG Q_ASSERT(noBlockInString(text.mid(fragments.fragment(x)->stringPosition, length))); +#endif blocks.setSize(b, blocks.size(b)-length); @@ -630,7 +636,9 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O if (key+1 != blocks.position(b)) { // qDebug("remove_string from %d length %d", key, X->size_array[0]); +#ifndef QT_NO_DEBUG Q_ASSERT(noBlockInString(text.mid(X->stringPosition, X->size_array[0]))); +#endif w = remove_string(key, X->size_array[0], op); if (needsInsert) { -- cgit v1.2.3