lupdate: fix duplicate location entries
TranslatorMessage::addReferenceUniq() checks whether a new source
reference is already recorded to avoid duplicates. When iterating over
the extra references (m_extraRefs), it compares the new reference's
startOffset against m_startOffset (the primary reference's offset)
instead of ref.startOffset() (the current loop reference's offset).
Since extra references always have a different offset from the primary
reference, the comparison always evaluates to false, and the duplicate
check never triggers for any extra reference. This causes duplicate
<location> entries in .ts files when lupdate processes the same source
file twice.
The double-processing happens, for example, when qt_add_translations is
called with both SOURCE_TARGETS and SOURCES naming the same file:
SOURCE_TARGETS collects the file from the target's source list, while
SOURCES adds it again explicitly. The bug only manifests for tr()
strings that appear more than once in the file, as the first (primary)
reference is deduplicated correctly.
Add a regression test that passes the same source file twice on the
command line to trigger the double-processing.
Pick-to: 6.11
Fixes: QTBUG-145179
Change-Id: I3e5954a0924f73eab78b994aea7264c0bba6197b
Reviewed-by: Masoud Jami <masoud.jami@qt.io>