summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qmetatype.h8
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp21
2 files changed, 24 insertions, 5 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 2c2dbeef9d..55f8fc9b2c 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1364,15 +1364,15 @@ namespace QtPrivate
enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(void*) };
};
- char qt_getEnumMetaObject(...);
- char qt_getEnumMetaObject(); // Workaround bugs in MSVC.
+ template<typename T> char qt_getEnumMetaObject(const T&);
template<typename T>
struct IsQEnumHelper {
static const T &declval();
- // If the type was declared with Q_ENUM, the friend qt_getEnumMetaObject(T) declared in the
+ // If the type was declared with Q_ENUM, the friend qt_getEnumMetaObject() declared in the
// Q_ENUM macro will be chosen by ADL, and the return type will be QMetaObject*.
- // Otherwise the chosen overload will be qt_getEnumMetaObject(...) which returne 'char'
+ // Otherwise the chosen overload will be the catch all template function
+ // qt_getEnumMetaObject(T) which returns 'char'
enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) };
};
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 94242607f0..263cc5a07a 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -127,6 +127,7 @@ private slots:
void connectConvert();
void connectWithReference();
void connectManyArguments();
+ void connectForwardDeclare();
void returnValue_data();
void returnValue();
void returnValue2_data();
@@ -5208,6 +5209,24 @@ void tst_QObject::connectManyArguments()
QCOMPARE(ManyArgumentNamespace::count, 12);
}
+class ForwardDeclared;
+
+class ForwardDeclareArguments : public QObject
+{
+ Q_OBJECT
+signals:
+ void mySignal(const ForwardDeclared&);
+public slots:
+ void mySlot(const ForwardDeclared&) {}
+};
+
+void tst_QObject::connectForwardDeclare()
+{
+ ForwardDeclareArguments ob;
+ // it should compile
+ QVERIFY(connect(&ob, &ForwardDeclareArguments::mySignal, &ob, &ForwardDeclareArguments::mySlot, Qt::QueuedConnection));
+}
+
class ReturnValue : public QObject {
friend class tst_QObject;
Q_OBJECT