|| ch == QTextEndOfFrame;
}
-#ifndef QT_NO_DEBUG
+#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
static bool noBlockInString(const QString &str)
{
return !str.contains(QChar::ParagraphSeparator)
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);
if (str.size() == 0)
return;
-#ifndef QT_NO_DEBUG
Q_ASSERT(noBlockInString(str));
-#endif
int strPos = text.length();
text.append(str);
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);
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) {
SectionSpan span(size, (end - start) + 1, mode);
int start_section = 0;
-#ifndef QT_NO_DEBUG
+#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
int initial_section_count = headerSectionCount(); // ### debug code
#endif
sectionSpans[i].resizeMode = mode;
// ### check if we can merge the section with any of its neighbours
removeSpans(spansToRemove);
-#ifndef QT_NO_DEBUG
Q_ASSERT(initial_section_count == headerSectionCount());
-#endif
return;
} else if (start > start_section && end < end_section) {
if (sectionSpans.at(i).sectionSize() == span.sectionSize()
&& sectionSpans.at(i).resizeMode == span.resizeMode) {
-#ifndef QT_NO_DEBUG
Q_ASSERT(initial_section_count == headerSectionCount());
-#endif
return;
}
// the new span is in the middle of the old span, so we have to split it
sectionSpans[i].resizeMode = span_mode;
length += first_span_size;
// middle span (the new span)
-#ifndef QT_NO_DEBUG
+#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
int mid_span_count = span.count;
#endif
int mid_span_size = span.size;
int last_span_size = section_size * last_span_count;
sectionSpans.insert(i + 2, SectionSpan(last_span_size, last_span_count, span_mode));
length += last_span_size;
-#ifndef QT_NO_DEBUG
Q_ASSERT(span_count == first_span_count + mid_span_count + last_span_count);
-#endif
removeSpans(spansToRemove);
-#ifndef QT_NO_DEBUG
Q_ASSERT(initial_section_count == headerSectionCount());
-#endif
return;
} else if (start > start_section && start <= end_section && end >= end_section) {
// the new span covers the last part of the existing span
sectionSpans.insert(i + 1, span); // insert after
length += span.size;
removeSpans(spansToRemove);
-#ifndef QT_NO_DEBUG
Q_ASSERT(initial_section_count == headerSectionCount());
-#endif
return;
}
} else if (end < end_section && end >= start_section && start <= start_section) {
sectionSpans.insert(i, span); // insert before
length += span.size;
removeSpans(spansToRemove);
-#ifndef QT_NO_DEBUG
Q_ASSERT(initial_section_count == headerSectionCount());
-#endif
return;
}
start_section += section_count;