From 2d7a87870c5646e9a11f994e0f5e3dbe49228ece Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 27 Apr 2015 20:36:32 +0200 Subject: [PATCH] update message index when message gains source text when a message which is first seen with only an id later gains a source text, this text would not have been indexed. so a subsequent new message with the same source, but without an id this time around, would not be seen as a dupe of the first message. Change-Id: Ib35f820e2b02311ea9c9996383a2789095098d6f Reviewed-by: hjk --- src/linguist/shared/translator.cpp | 2 ++ .../linguist/lupdate/testdata/good/parsecpp/main.cpp | 16 ++++++++++++++++ .../lupdate/testdata/good/parsecpp/project.ts.result | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/src/linguist/shared/translator.cpp b/src/linguist/shared/translator.cpp index 94d3bc3..f976596 100644 --- a/src/linguist/shared/translator.cpp +++ b/src/linguist/shared/translator.cpp @@ -151,7 +151,9 @@ void Translator::extend(const TranslatorMessage &msg, ConversionData &cd) } else { TranslatorMessage &emsg = m_messages[index]; if (emsg.sourceText().isEmpty()) { + delIndex(index); emsg.setSourceText(msg.sourceText()); + addIndex(index, msg); } else if (!msg.sourceText().isEmpty() && emsg.sourceText() != msg.sourceText()) { cd.appendError(QString::fromLatin1("Contradicting source strings for message with id '%1'.") .arg(emsg.id())); diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 074ed66..4fdd489 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -394,3 +394,19 @@ Class42::hello(int something /*= 17 */, QString str = Class42::tr("eyo")) // test TR_EXCLUDE #include "notincluded.cpp" + + + +// failure to update index on insertion messes up subsequent de-duplication +int dupeFail() +{ + // First just the Id. + qtTrId("dupe_id"); + + // Then with source + //% "This is the source" + qtTrId("dupe_id"); + + // Finally, same source, but without ID. + QCoreApplication::translate("", "This is the source"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index c0a4a83..0c0c1b5 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -24,6 +24,13 @@ backslashed \ stuff. This is a message without a source string + + + + + This is the source + + Bogus -- 2.7.4