[Development] QHash references stability in Qt6

Fabian Kosmale fabian.kosmale at qt.io
Thu Mar 18 16:11:31 CET 2021

Yes, as described in https://doc.qt.io/qt-6/qtcore-changes-qt6.html#stability-of-references, Qt 6's QHash does indeed intentionally no longer promise reference stability when it grows or elements are removed.
Fabian Kosmale
Software Engineer

The Qt Company GmbH
Erich-Thilo-Str. 10
D-12489 Berlin
fabian.kosmale at qt.io
+49 1638686070

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 144331 B


Von: Development <development-bounces at qt-project.org> im Auftrag von Иван Комиссаров <abbapoh at gmail.com>
Gesendet: Donnerstag, 18. März 2021 16:04
An: Qt development mailing list
Betreff: [Development] QHash references stability in Qt6

Hello, when porting Qbs to Qt6 I’ve noticed a lot of bugs/crashes when using QHash. With Qt5 that was never a problem and simple change QHash -> std::unordered_map fixes those.

From what I understood all affected places rely on the fact that QHash in Qt5 (as well as std::unordered_map) guarantees that references are not invalidated even in case of re-hashing.

So I am wondering if this is the case with the new QHash implementation or is it just a bug (I could not find anything related on the bug tracker though)

Development mailing list
Development at qt-project.org

More information about the Development mailing list