[Development] invokeMethod() with function pointers

Benjamin TERRIER b.terrier at gmail.com
Thu Jan 19 12:24:34 CET 2017


Hi,

I've got an issue.

Adding

template <typename Func>
static typename
QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func>::IsPointerToMemberFunction
  && QtPrivate::FunctionPointer<Func>::ArgumentCount == -1
  && !std::is_same<const char*, Func>::value, bool>::Type
  invokeMethod(QObject *object, Func function)

to QMetaObject breaks existing code and the auto tests in particular.

In tst_qmetaobject.cpp there is this test:
QVERIFY(!QMetaObject::invokeMethod(&obj, 0));
because the new overload of invokeMethod() gets called this lead to
compilation error instead
of just returning false at run-time.

To solve the issue one must add an explicit cast like so:
QVERIFY(!QMetaObject::invokeMethod(&obj, (const char*)0));
Note that casting to "char *" does not solve the issue.

Is this "source break"  acceptable (it might be looking at "Source
break policy for function overloads" discussion and quip 6) and the
autotests should be fixed?
Or should another solution be found (Thiago proposed to use a
different name in QTBUG-37253)?

Thanks

Regards,

Benjamin



More information about the Development mailing list