summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/linguist/shared/translator.cpp2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp16
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result7
3 files changed, 25 insertions, 0 deletions
diff --git a/src/linguist/shared/translator.cpp b/src/linguist/shared/translator.cpp
index 94d3bc305..f976596ff 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 074ed6611..4fdd489b6 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 c0a4a83b2..0c0c1b511 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.</source>
<extracomment>This is a message without a source string</extracomment>
<translation type="unfinished"></translation>
</message>
+ <message id="dupe_id">
+ <location filename="main.cpp" line="404"/>
+ <location filename="main.cpp" line="408"/>
+ <location filename="main.cpp" line="411"/>
+ <source>This is the source</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>Bogus</name>