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 <ogoffart@woboq.com>
This commit is contained in:
parent
611c0081ff
commit
dee57bc910
@ -1003,7 +1003,7 @@ int QCoreApplication::exec()
|
||||
if (self) {
|
||||
self->d_func()->in_exec = false;
|
||||
if (!self->d_func()->aboutToQuitEmitted)
|
||||
emit self->aboutToQuit();
|
||||
emit self->aboutToQuit(QPrivateSignal());
|
||||
self->d_func()->aboutToQuitEmitted = true;
|
||||
sendPostedEvents(0, QEvent::DeferredDelete);
|
||||
}
|
||||
|
@ -166,8 +166,16 @@ public Q_SLOTS:
|
||||
static void quit();
|
||||
|
||||
Q_SIGNALS:
|
||||
void aboutToQuit();
|
||||
void unixSignal(int);
|
||||
void aboutToQuit(
|
||||
#if !defined(qdoc)
|
||||
QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
void unixSignal(int
|
||||
#if !defined(qdoc)
|
||||
, QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *);
|
||||
|
@ -191,7 +191,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
|
||||
for (int i = 0; i < NSIG; ++i) {
|
||||
if (signals_fired[i]) {
|
||||
signals_fired[i] = 0;
|
||||
emit QCoreApplication::instance()->unixSignal(i);
|
||||
emit QCoreApplication::instance()->unixSignal(i, QCoreApplication::QPrivateSignal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ void QObject::setObjectName(const QString &name)
|
||||
|
||||
if (d->extraData->objectName != name) {
|
||||
d->extraData->objectName = name;
|
||||
emit objectNameChanged(d->extraData->objectName);
|
||||
emit objectNameChanged(d->extraData->objectName, QPrivateSignal());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,11 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void destroyed(QObject * = 0);
|
||||
void objectNameChanged(const QString &objectName);
|
||||
void objectNameChanged(const QString &objectName
|
||||
#if !defined(qdoc)
|
||||
, QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
|
||||
public:
|
||||
inline QObject *parent() const { return d_ptr->parent; }
|
||||
|
@ -298,7 +298,7 @@ bool QSocketNotifier::event(QEvent *e)
|
||||
}
|
||||
QObject::event(e); // will activate filters
|
||||
if ((e->type() == QEvent::SockAct) || (e->type() == QEvent::SockClose)) {
|
||||
emit activated(d->sockfd);
|
||||
emit activated(d->sockfd, QPrivateSignal());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -69,7 +69,11 @@ public Q_SLOTS:
|
||||
void setEnabled(bool);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activated(int socket);
|
||||
void activated(int socket
|
||||
#if !defined(qdoc)
|
||||
, QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *);
|
||||
|
@ -247,7 +247,7 @@ void QTimer::timerEvent(QTimerEvent *e)
|
||||
if (e->timerId() == id) {
|
||||
if (single)
|
||||
stop();
|
||||
emit timeout();
|
||||
emit timeout(QPrivateSignal());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,11 @@ public Q_SLOTS:
|
||||
void stop();
|
||||
|
||||
Q_SIGNALS:
|
||||
void timeout();
|
||||
void timeout(
|
||||
#if !defined(qdoc)
|
||||
QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *);
|
||||
|
@ -234,7 +234,7 @@ bool QWinEventNotifier::event(QEvent * e)
|
||||
}
|
||||
QObject::event(e); // will activate filters
|
||||
if (e->type() == QEvent::WinEventAct) {
|
||||
emit activated(d->handleToEvent);
|
||||
emit activated(d->handleToEvent, QPrivateSignal());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -74,7 +74,11 @@ public Q_SLOTS:
|
||||
void setEnabled(bool enable);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activated(HANDLE hEvent);
|
||||
void activated(HANDLE hEvent
|
||||
#if !defined(qdoc)
|
||||
, QPrivateSignal
|
||||
#endif
|
||||
);
|
||||
|
||||
protected:
|
||||
bool event(QEvent * e);
|
||||
|
@ -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)))); \
|
||||
}
|
||||
|
||||
|
@ -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<QMenu*>(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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user