QSocketNotifier: hone setSocket() API
Remove a second argument to the setSocket(qintptr, bool) function as it makes the API harder to understand. Change-Id: Ib1852a4e9d96adde35bfbf0fe03b386d9ded395a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>bb10
parent
1649137b93
commit
7a4e686240
|
|
@ -235,20 +235,19 @@ QSocketNotifier::~QSocketNotifier()
|
|||
/*!
|
||||
\since 6.1
|
||||
|
||||
Assigns the \a socket to this notifier. The \a enable argument is
|
||||
passed to the setEnabled() function.
|
||||
Assigns the \a socket to this notifier.
|
||||
|
||||
\note The notifier will be disabled as a side effect and needs
|
||||
to be re-enabled.
|
||||
|
||||
\sa setEnabled(), isValid()
|
||||
*/
|
||||
void QSocketNotifier::setSocket(qintptr socket, bool enable)
|
||||
void QSocketNotifier::setSocket(qintptr socket)
|
||||
{
|
||||
Q_D(QSocketNotifier);
|
||||
|
||||
if (d->sockfd != QSocketDescriptor(socket)) {
|
||||
setEnabled(false);
|
||||
d->sockfd = socket;
|
||||
}
|
||||
setEnabled(enable);
|
||||
setEnabled(false);
|
||||
d->sockfd = socket;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
QSocketNotifier(qintptr socket, Type, QObject *parent = nullptr);
|
||||
~QSocketNotifier();
|
||||
|
||||
void setSocket(qintptr socket, bool enable = false);
|
||||
void setSocket(qintptr socket);
|
||||
qintptr socket() const;
|
||||
Type type() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ void tst_QSocketNotifier::constructing()
|
|||
notifier.setEnabled(true);
|
||||
QVERIFY(!notifier.isEnabled());
|
||||
|
||||
notifier.setSocket(fd, true);
|
||||
notifier.setSocket(fd);
|
||||
QVERIFY(notifier.isValid());
|
||||
QCOMPARE(notifier.socket(), fd);
|
||||
QVERIFY(notifier.isEnabled());
|
||||
notifier.setEnabled(false);
|
||||
QVERIFY(!notifier.isEnabled());
|
||||
notifier.setEnabled(true);
|
||||
QVERIFY(notifier.isEnabled());
|
||||
}
|
||||
|
||||
// Test constructing with the notifications enabled by default.
|
||||
|
|
@ -119,12 +119,12 @@ void tst_QSocketNotifier::constructing()
|
|||
QCOMPARE(notifier.type(), QSocketNotifier::Write);
|
||||
QVERIFY(notifier.isEnabled());
|
||||
|
||||
notifier.setSocket(fd, false);
|
||||
notifier.setSocket(fd);
|
||||
QVERIFY(!notifier.isEnabled());
|
||||
|
||||
notifier.setEnabled(true);
|
||||
QVERIFY(notifier.isEnabled());
|
||||
notifier.setSocket(-1, true);
|
||||
notifier.setSocket(-1);
|
||||
QVERIFY(!notifier.isValid());
|
||||
QCOMPARE(notifier.socket(), Q_INT64_C(-1));
|
||||
QVERIFY(!notifier.isEnabled());
|
||||
|
|
|
|||
Loading…
Reference in New Issue