From dee57bc91080740201a0bf0b8c42eb374ee696f3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 18 Oct 2012 14:29:06 +0200 Subject: Core/kernel: Make some signals private. There are more opportunities in QtCore and the rest of Qt to make signals private instead of public. This is a test-dart to see if there is any reason not to do this. It would be nice to make QObject::destroyed private, but as it has a default argument it would be source incompatible to anyone connecting to the SIGNAL(destroyed()) instead of SIGNAL(destroyed(QObject*)). Currently the function-pointer-based connect syntax does not accept a functor (or lambda) with a different number of arguments than the signal. Olivier says a fix for that might come in 5.1, but for now the qfiledialog2 test is changed to not use that anymore. Also, the function pointer for a private signal can not be assigned to a local variable, so the qmetamethod test is changed to not do so anymore. Change-Id: Iaf776b822f9ba364f2c184df0c6b23811da56e44 Reviewed-by: Olivier Goffart --- tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp | 3 +-- tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp index 1ef2cf8e3f..526a5039b0 100644 --- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp +++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp @@ -714,9 +714,8 @@ void tst_QMetaMethod::comparisonOperators() void tst_QMetaMethod::fromSignal() { #define FROMSIGNAL_HELPER(ObjectType, Name, Arguments) { \ - void (ObjectType::*signal)Arguments = &ObjectType::Name; \ const QMetaObject *signalMeta = &ObjectType::staticMetaObject; \ - QCOMPARE(QMetaMethod::fromSignal(signal), \ + QCOMPARE(QMetaMethod::fromSignal(&ObjectType::Name), \ signalMeta->method(signalMeta->indexOfSignal(QMetaObject::normalizedSignature(#Name #Arguments)))); \ } diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index b4985df8d4..54663ba3a3 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -319,10 +319,11 @@ void tst_QFileDialog2::emptyUncPath() } #if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_MENU) -struct MenuCloser { +struct MenuCloser : public QObject { QWidget *w; explicit MenuCloser(QWidget *w) : w(w) {} - void operator()() const + + void close() { QMenu *menu = qFindChild(w); if (!menu) { @@ -342,7 +343,8 @@ static bool openContextMenu(QFileDialog &fd) QTimer timer; timer.setInterval(300); timer.setSingleShot(true); - QObject::connect(&timer, &QTimer::timeout, MenuCloser(&fd)); + MenuCloser closer(&fd); + QObject::connect(&timer, &QTimer::timeout, &closer, &MenuCloser::close); timer.start(); QContextMenuEvent cme(QContextMenuEvent::Mouse, QPoint(10, 10)); qApp->sendEvent(list->viewport(), &cme); // blocks until menu is closed again. -- cgit v1.2.3