From e63b831bbdee89decbe8c2f06110e8ac56ef9e2b Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@woboq.com>
Date: Sat, 18 May 2013 16:26:16 +0200
Subject: [PATCH] moc: Fix Generator::registerableMetaType

when the type is a pointer to a registerable 1 argument template type.

Task-number: QTBUG-31002
Change-Id: Iac0d6b71b2b805a1876110a0781d02188083c4e5
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
---
 src/tools/moc/generator.cpp      | 4 ++--
 tests/auto/tools/moc/tst_moc.cpp | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index e6ffbe157ad..44eb4f65e82 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -172,12 +172,12 @@ bool Generator::registerableMetaType(const QByteArray &propertyType)
 #undef STREAM_1ARG_TEMPLATE
     ;
     foreach (const QByteArray &oneArgTemplateType, oneArgTemplates)
-        if (propertyType.startsWith(oneArgTemplateType + "<") && !propertyType.endsWith("&")) {
+        if (propertyType.startsWith(oneArgTemplateType + "<") && propertyType.endsWith(">")) {
             const int argumentSize = propertyType.size() - oneArgTemplateType.size() - 1
                                      // The closing '>'
                                      - 1
                                      // templates inside templates have an extra whitespace char to strip.
-                                     - (propertyType.at(propertyType.size() - 2) == '>' ? 1 : 0 );
+                                     - (propertyType.at(propertyType.size() - 2) == ' ' ? 1 : 0 );
             const QByteArray templateArg = propertyType.mid(oneArgTemplateType.size() + 1, argumentSize);
             return isBuiltinType(templateArg) || registerableMetaType(templateArg);
         }
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 923275d9284..3459bede85c 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -325,6 +325,8 @@ public slots:
 signals:
     void signalWithArray(const double[3]);
     void signalWithNamedArray(const double namedArray[3]);
+    void signalWithIterator(QList<QUrl>::iterator);
+    void signalWithListPointer(QList<QUrl>*); //QTBUG-31002
 
 private slots:
     // for tst_Moc::preprocessorConditionals
-- 
GitLab