From 48a45d0cd4f860419502832d4ffb8b2a7217d525 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 4 Jun 2016 14:15:26 +0000 Subject: [PATCH] build fixes for the QT_STRICT_ITERATORS conditional the only thing left to fix is the dbus component which requires the pointer operator backported from https://github.com/qtproject/qtbase/commit/9c5a77f0ef0b2ace0b11719142115eded4a7c05e but it messes up the erase and insert templates and causes source incompatibilities so it has to investigated further. upstream commits: https://github.com/qtproject/qtbase/commit/fad1fa65ed2a76539a229acaa83299875ce8b4c1 https://github.com/qtproject/qtbase/commit/7c1e0fef8e35ecd8487c41dc39e7ce46537f3040 https://github.com/qtproject/qtbase/commit/c4fbe872be1316f2fd65aa62863d6617cb129a3f https://github.com/qtproject/qtbase/commit/0412ad35132e0de008d601912ded1f147014cab1 Signed-off-by: Ivailo Monev --- src/core/tools/qcommandlineparser.cpp | 2 +- src/dbus/qdbusintegrator.cpp | 6 +-- src/designer/shared/qtresourcemodel.cpp | 4 +- src/designer/shared/qtresourceview.cpp | 2 +- src/gui/dialogs/qfilesystemmodel.cpp | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 8 +-- src/gui/itemviews/qsortfilterproxymodel.cpp | 2 +- src/gui/itemviews/qtreeview.cpp | 4 +- src/gui/kernel/qapplication_x11.cpp | 2 +- src/gui/kernel/qgesturemanager.cpp | 37 +++++++------- src/gui/text/qtextengine.cpp | 56 +++------------------ src/gui/text/qtextengine_p.h | 1 - src/gui/text/qtextformat.cpp | 4 +- src/help/qhelpgenerator.cpp | 4 +- src/help/qhelpprojectdata.cpp | 2 +- src/help/qhelpsearchindexreader_default.cpp | 10 ++-- src/help/qhelpsearchindexwriter_default.cpp | 2 +- 17 files changed, 52 insertions(+), 96 deletions(-) diff --git a/src/core/tools/qcommandlineparser.cpp b/src/core/tools/qcommandlineparser.cpp index 269c92749..abcf274b1 100644 --- a/src/core/tools/qcommandlineparser.cpp +++ b/src/core/tools/qcommandlineparser.cpp @@ -704,7 +704,7 @@ QString QCommandLineParser::value(const QString &optionName) const QStringList QCommandLineParser::values(const QString &optionName) const { d->checkParsed("values"); - const NameHash_t::const_iterator it = d->nameHash.find(optionName); + const NameHash_t::const_iterator it = d->nameHash.constFind(optionName); if (it != d->nameHash.constEnd()) { const int optionOffset = *it; QStringList values = d->optionValuesHash.value(optionOffset); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index f64db2eed..e2566b831 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1546,7 +1546,7 @@ void QDBusActivateObjectEvent::placeMetaCall(QObject *) void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage& msg) { - SignalHookHash::const_iterator it = signalHooks.find(key); + SignalHookHash::const_iterator it = signalHooks.constFind(key); SignalHookHash::const_iterator end = signalHooks.constEnd(); //qDebug("looking for: %s", path.toLocal8Bit().constData()); //qDBusDebug() << signalHooks.keys(); @@ -2077,7 +2077,7 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service, return false; // don't connect // avoid duplicating: - QDBusConnectionPrivate::SignalHookHash::ConstIterator it = signalHooks.find(key); + QDBusConnectionPrivate::SignalHookHash::ConstIterator it = signalHooks.constFind(key); QDBusConnectionPrivate::SignalHookHash::ConstIterator end = signalHooks.constEnd(); for ( ; it != end && it.key() == key; ++it) { const QDBusConnectionPrivate::SignalHook &entry = it.value(); @@ -2272,7 +2272,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, // add it to our list: QDBusWriteLocker locker(ConnectRelayAction, this); - SignalHookHash::ConstIterator it = signalHooks.find(key); + SignalHookHash::ConstIterator it = signalHooks.constFind(key); SignalHookHash::ConstIterator end = signalHooks.constEnd(); for ( ; it != end && it.key() == key; ++it) { const SignalHook &entry = it.value(); diff --git a/src/designer/shared/qtresourcemodel.cpp b/src/designer/shared/qtresourcemodel.cpp index d99406445..2529eb717 100644 --- a/src/designer/shared/qtresourcemodel.cpp +++ b/src/designer/shared/qtresourcemodel.cpp @@ -501,7 +501,7 @@ QStringList QtResourceModel::loadedQrcFiles() const bool QtResourceModel::isModified(const QString &path) const { - QMap::const_iterator it = d_ptr->m_pathToModified.find(path); + QMap::const_iterator it = d_ptr->m_pathToModified.constFind(path); if (it != d_ptr->m_pathToModified.constEnd()) return it.value(); return true; @@ -509,7 +509,7 @@ bool QtResourceModel::isModified(const QString &path) const void QtResourceModel::setModified(const QString &path) { - QMap::const_iterator itMod = d_ptr->m_pathToModified.find(path); + QMap::const_iterator itMod = d_ptr->m_pathToModified.constFind(path); if (itMod == d_ptr->m_pathToModified.constEnd()) return; diff --git a/src/designer/shared/qtresourceview.cpp b/src/designer/shared/qtresourceview.cpp index 8950ddef1..30addb252 100644 --- a/src/designer/shared/qtresourceview.cpp +++ b/src/designer/shared/qtresourceview.cpp @@ -673,7 +673,7 @@ void QtResourceView::selectResource(const QString &resource) dir = QDir(resource); QString dirPath = dir.absolutePath(); QMap::const_iterator it; - while ((it = d_ptr->m_pathToItem.find(dirPath)) == d_ptr->m_pathToItem.constEnd()) { + while ((it = d_ptr->m_pathToItem.constFind(dirPath)) == d_ptr->m_pathToItem.constEnd()) { if (!dir.cdUp()) break; dirPath = dir.absolutePath(); diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 3f47ae996..095509f55 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1124,7 +1124,7 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent QList > values; QHash::const_iterator iterator; int i = 0; - for(iterator = indexNode->children.begin() ; iterator != indexNode->children.end() ; ++iterator) { + for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) { if (filtersAcceptsNode(iterator.value())) { values.append(QPair((iterator.value()), i)); } else { diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 391bc82a1..37e1729d6 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4186,8 +4186,8 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) // Find the first popup under the mouse (including the popup's descendants) starting from the last. // Remove all popups after the one found, or all or them if no popup is under the mouse. // Then continue with the event. - QList::const_iterator iter = d->popupWidgets.end(); - while (--iter >= d->popupWidgets.begin() && !wheelCandidates.isEmpty()) { + QList::const_iterator iter = d->popupWidgets.constEnd(); + while (--iter >= d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) { if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first())) break; d->removePopup(*iter); @@ -6116,8 +6116,8 @@ void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet &ges if (QGraphicsObject *itemobj = item->toGraphicsObject()) { QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); QMap::const_iterator it = - d->gestureContext.find(gestureType); - if (it != d->gestureContext.end() && (!flag || (it.value() & flag))) { + d->gestureContext.constFind(gestureType); + if (it != d->gestureContext.constEnd() && (!flag || (it.value() & flag))) { if (normalGestures.contains(gesture)) { normalGestures.remove(gesture); if (conflicts) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index dbb91abf5..3895d97dc 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -1119,7 +1119,7 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc if (!source_top_left.isValid() || !source_bottom_right.isValid()) return; QModelIndex source_parent = source_top_left.parent(); - IndexMap::const_iterator it = source_index_mapping.find(source_parent); + IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); if (it == source_index_mapping.constEnd()) { // Don't care, since we don't have mapping for this index return; diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 372404370..9feffc8cd 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2011,14 +2011,14 @@ void QTreeView::doItemsLayout() //clean the QSet that may contains old (and this invalid) indexes d->hasRemovedItems = false; QSet::iterator it = d->expandedIndexes.begin(); - while (it != d->expandedIndexes.constEnd()) { + while (it != d->expandedIndexes.end()) { if (!it->isValid()) it = d->expandedIndexes.erase(it); else ++it; } it = d->hiddenIndexes.begin(); - while (it != d->hiddenIndexes.constEnd()) { + while (it != d->hiddenIndexes.end()) { if (!it->isValid()) it = d->hiddenIndexes.erase(it); else diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 8986471fc..4a80c8edd 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -3111,7 +3111,7 @@ void qPRCleanup(QWidget *widget) if (!(wPRmapper && widget->testAttribute(Qt::WA_WState_Reparented))) return; // not a reparented widget QWidgetMapper::Iterator it = wPRmapper->begin(); - while (it != wPRmapper->constEnd()) { + while (it != wPRmapper->end()) { QWidget *w = *it; if (w == etw) { // found widget etw->setAttribute(Qt::WA_WState_Reparented, false); // clear flag diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 219634bdb..911846e99 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -142,8 +142,8 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) } } - QMap >::const_iterator iter = m_objectGestures.begin(); - while (iter != m_objectGestures.end()) { + QMap >::const_iterator iter = m_objectGestures.constBegin(); + while (iter != m_objectGestures.constEnd()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type) { foreach (QGesture *g, iter.value()) { @@ -250,9 +250,10 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap &const_recognizers = m_recognizers; QMap::const_iterator - typeToRecognizerIterator = m_recognizers.lowerBound(gestureType), - typeToRecognizerEnd = m_recognizers.upperBound(gestureType); + typeToRecognizerIterator = const_recognizers.lowerBound(gestureType), + typeToRecognizerEnd = const_recognizers.upperBound(gestureType); for (; typeToRecognizerIterator != typeToRecognizerEnd; ++typeToRecognizerIterator) { QGestureRecognizer *recognizer = typeToRecognizerIterator.value(); QObject *target = context.key(); @@ -470,8 +471,8 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) QWidget *w = receiver; typedef QMap::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { - for(ContextIterator it = w->d_func()->gestureContext.begin(), - e = w->d_func()->gestureContext.end(); it != e; ++it) { + for(ContextIterator it = w->d_func()->gestureContext.constBegin(), + e = w->d_func()->gestureContext.constEnd(); it != e; ++it) { types.insert(it.key(), 0); contexts.insertMulti(w, it.key()); } @@ -480,8 +481,8 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) w = w->isWindow() ? 0 : w->parentWidget(); while (w) { - for (ContextIterator it = w->d_func()->gestureContext.begin(), - e = w->d_func()->gestureContext.end(); it != e; ++it) { + for (ContextIterator it = w->d_func()->gestureContext.constBegin(), + e = w->d_func()->gestureContext.constEnd(); it != e; ++it) { if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { types.insert(it.key(), 0); @@ -504,8 +505,8 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap::const_iterator ContextIterator; - for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), - e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { + for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(), + e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) { types.insert(it.key(), 0); contexts.insertMulti(item, it.key()); } @@ -515,8 +516,8 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) while (item) { typedef QMap::const_iterator ContextIterator; - for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), - e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { + for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(), + e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) { if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { types.insert(it.key(), 0); @@ -561,8 +562,8 @@ void QGestureManager::getGestureTargets(const QSet &gestures, QWidget *w = widget->parentWidget(); while (w) { QMap::const_iterator it - = w->d_func()->gestureContext.find(type); - if (it != w->d_func()->gestureContext.end()) { + = w->d_func()->gestureContext.constFind(type); + if (it != w->d_func()->gestureContext.constEnd()) { // i.e. 'w' listens to gesture 'type' if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) { // conflicting gesture! @@ -644,8 +645,8 @@ void QGestureManager::deliverEvents(const QSet &gestures, << "\n"; // if there are conflicting gestures, send the GestureOverride event - for (GesturesPerWidget::const_iterator it = conflictedGestures.begin(), - e = conflictedGestures.end(); it != e; ++it) { + for (GesturesPerWidget::const_iterator it = conflictedGestures.constBegin(), + e = conflictedGestures.constEnd(); it != e; ++it) { QWidget *receiver = it.key(); QList gestures = it.value(); DEBUG() << "QGestureManager::deliverEvents: sending GestureOverride to" @@ -678,8 +679,8 @@ void QGestureManager::deliverEvents(const QSet &gestures, } // delivering gestures that are not in conflicted state - for (GesturesPerWidget::const_iterator it = normalStartedGestures.begin(), - e = normalStartedGestures.end(); it != e; ++it) { + for (GesturesPerWidget::const_iterator it = normalStartedGestures.constBegin(), + e = normalStartedGestures.constEnd(); it != e; ++it) { if (!it.value().isEmpty()) { DEBUG() << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value(); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 9332e7caf..d3ce5677b 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2647,61 +2647,17 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int return layoutData->string; } -namespace { -struct QScriptItemComparator { - bool operator()(const QScriptItem &a, const QScriptItem &b) { return a.position < b.position; } - bool operator()(int p, const QScriptItem &b) { return p < b.position; } - //bool operator()(const QScriptItem &a, int p) { return a.position < p; } -}; -} - void QTextEngine::setBoundary(int strPos) const { - if (strPos <= 0 || strPos >= layoutData->string.length()) + const int item = findItem(strPos); + if (item < 0) return; - const QScriptItem* it = qUpperBound(layoutData->items.constBegin(), layoutData->items.constEnd(), - strPos, QScriptItemComparator()); - Q_ASSERT(it > layoutData->items.constBegin()); - --it; - if (it->position == strPos) { - // already a split at the requested position - return; + QScriptItem newItem = layoutData->items.at(item); + if (newItem.position != strPos) { + newItem.position = strPos; + layoutData->items.insert(item + 1, newItem); } - splitItem(it - layoutData->items.constBegin(), strPos - it->position); -} - -void QTextEngine::splitItem(int item, int pos) const -{ - if (pos <= 0) - return; - - layoutData->items.insert(item + 1, layoutData->items[item]); - QScriptItem &oldItem = layoutData->items[item]; - QScriptItem &newItem = layoutData->items[item+1]; - newItem.position += pos; - - if (oldItem.num_glyphs) { - // already shaped, break glyphs aswell - int breakGlyph = logClusters(&oldItem)[pos]; - - newItem.num_glyphs = oldItem.num_glyphs - breakGlyph; - oldItem.num_glyphs = breakGlyph; - newItem.glyph_data_offset = oldItem.glyph_data_offset + breakGlyph; - - for (int i = 0; i < newItem.num_glyphs; i++) - logClusters(&newItem)[i] -= breakGlyph; - - QFixed w = 0; - const QGlyphLayout g = shapedGlyphs(&oldItem); - for(int j = 0; j < breakGlyph; ++j) - w += g.advances_x[j] * !g.attributes[j].dontPrint; - - newItem.width = oldItem.width - w; - oldItem.width = w; - } - -// qDebug("split at position %d itempos=%d", pos, item); } QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index abedf290f..886d18934 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -618,7 +618,6 @@ private: #if defined(Q_WS_MAC) void shapeTextMac(int item) const; #endif - void splitItem(int item, int pos) const; void resolveAdditionalFormats() const; int endOfLine(int lineNum); diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index cc9208ff4..38e525ed1 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -3233,8 +3233,8 @@ QTextFormatCollection::~QTextFormatCollection() int QTextFormatCollection::indexForFormat(const QTextFormat &format) { uint hash = getHash(format.d, format.format_type); - QMultiHash::const_iterator i = hashes.find(hash); - while (i != hashes.end() && i.key() == hash) { + QMultiHash::const_iterator i = hashes.constFind(hash); + while (i != hashes.constEnd() && i.key() == hash) { if (formats.value(i.value()) == format) { return i.value(); } diff --git a/src/help/qhelpgenerator.cpp b/src/help/qhelpgenerator.cpp index 969e14de9..ff7c9d63d 100644 --- a/src/help/qhelpgenerator.cpp +++ b/src/help/qhelpgenerator.cpp @@ -733,8 +733,8 @@ bool QHelpGenerator::insertKeywords(const QList &keywords, if (fName.startsWith(QLatin1String("./"))) fName = fName.mid(2); - QMap::ConstIterator it = d->fileMap.find(fName); - if (it != d->fileMap.end()) + QMap::ConstIterator it = d->fileMap.constFind(fName); + if (it != d->fileMap.constEnd()) fileId = it.value(); else fileId = 1; diff --git a/src/help/qhelpprojectdata.cpp b/src/help/qhelpprojectdata.cpp index 939f421c0..1d657d477 100644 --- a/src/help/qhelpprojectdata.cpp +++ b/src/help/qhelpprojectdata.cpp @@ -294,7 +294,7 @@ void QHelpProjectDataPrivate::addMatchingFiles(const QString &pattern) const QString &path = dir.canonicalPath(); // QDir::entryList() is expensive, so we cache the results. - QMap::ConstIterator it = dirEntriesCache.find(path); + QMap::ConstIterator it = dirEntriesCache.constFind(path); const QStringList &entries = it != dirEntriesCache.constEnd() ? it.value() : dir.entryList(QDir::Files); if (it == dirEntriesCache.constEnd()) diff --git a/src/help/qhelpsearchindexreader_default.cpp b/src/help/qhelpsearchindexreader_default.cpp index 57e0a5def..206ce3cdb 100644 --- a/src/help/qhelpsearchindexreader_default.cpp +++ b/src/help/qhelpsearchindexreader_default.cpp @@ -161,7 +161,7 @@ void Reader::setIndexPath(const QString &path) void Reader::filterFilesForAttributes(const QStringList &attributes) { searchIndexTable.clear(); - for(IndexTable::ConstIterator it = indexTable.begin(); it != indexTable.end(); ++it) { + for(IndexTable::ConstIterator it = indexTable.constBegin(); it != indexTable.constEnd(); ++it) { const QString fileName = it.key(); bool containsAll = true; QStringList split = fileName.split(QLatin1String("@")); @@ -237,8 +237,8 @@ void Reader::searchInIndex(const QStringList &terms) foreach (const QString &term, terms) { QVector documents; - for(IndexTable::ConstIterator it = searchIndexTable.begin(); - it != searchIndexTable.end(); ++it) { + for(IndexTable::ConstIterator it = searchIndexTable.constBegin(); + it != searchIndexTable.constEnd(); ++it) { EntryTable entryTable = it.value().first; DocumentList documentList = it.value().second; @@ -318,7 +318,7 @@ bool Reader::searchForPattern(const QStringList &patterns, const QStringList &wo return false; for(QHash::ConstIterator mit = - miniIndex.begin(); mit != miniIndex.end(); ++mit) { + miniIndex.constBegin(); mit != miniIndex.constEnd(); ++mit) { delete mit.value(); } miniIndex.clear(); @@ -483,7 +483,7 @@ void Reader::reset() void Reader::cleanupIndex(EntryTable &entryTable) { for(EntryTable::ConstIterator it = - entryTable.begin(); it != entryTable.end(); ++it) { + entryTable.constBegin(); it != entryTable.constEnd(); ++it) { delete it.value(); } diff --git a/src/help/qhelpsearchindexwriter_default.cpp b/src/help/qhelpsearchindexwriter_default.cpp index 9cc247e49..0de0e721d 100644 --- a/src/help/qhelpsearchindexwriter_default.cpp +++ b/src/help/qhelpsearchindexwriter_default.cpp @@ -74,7 +74,7 @@ Writer::~Writer() void Writer::reset() { for(QHash::ConstIterator it = - index.begin(); it != index.end(); ++it) { + index.constBegin(); it != index.constEnd(); ++it) { delete it.value(); }