QAbstractSocket::flush(): remove manual polymorphism

... by making a function in the private class virtual.

Change-Id: I45c25c6c59511a8e8821ca96b0cf28cbf1b2f267
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
bb10
Alex Trotsenko 2016-02-24 17:20:04 +02:00
parent b4b829d928
commit 6691df5336
5 changed files with 21 additions and 20 deletions

View File

@ -2397,15 +2397,7 @@ bool QAbstractSocket::atEnd() const
// Note! docs copied to QSslSocket::flush()
bool QAbstractSocket::flush()
{
Q_D(QAbstractSocket);
#ifndef QT_NO_SSL
// Manual polymorphism; flush() isn't virtual, but QSslSocket overloads
// it.
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
return socket->flush();
#endif
Q_CHECK_SOCKETENGINE(false);
return d->flush();
return d_func()->flush();
}
/*! \reimp

View File

@ -129,7 +129,7 @@ public:
inline void resolveProxy(quint16 port) { resolveProxy(QString(), port); }
void resetSocketLayer();
bool flush();
virtual bool flush();
bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol);
virtual void configureCreatedSocket();

View File

@ -834,15 +834,7 @@ bool QSslSocket::atEnd() const
// Note! docs copied from QAbstractSocket::flush()
bool QSslSocket::flush()
{
Q_D(QSslSocket);
#ifdef QSSLSOCKET_DEBUG
qCDebug(lcSsl) << "QSslSocket::flush()";
#endif
if (d->mode != UnencryptedMode)
// encrypt any unencrypted bytes in our buffer
d->transmit();
return d->plainSocket ? d->plainSocket->flush() : false;
return d_func()->flush();
}
/*!
@ -2579,6 +2571,22 @@ QByteArray QSslSocketPrivate::peek(qint64 maxSize)
}
}
/*!
\internal
*/
bool QSslSocketPrivate::flush()
{
#ifdef QSSLSOCKET_DEBUG
qCDebug(lcSsl) << "QSslSocketPrivate::flush()";
#endif
if (mode != QSslSocket::UnencryptedMode) {
// encrypt any unencrypted bytes in our buffer
transmit();
}
return plainSocket && plainSocket->flush();
}
/*!
\internal
*/

View File

@ -116,7 +116,7 @@ public:
bool canReadLine() const Q_DECL_OVERRIDE;
void close() Q_DECL_OVERRIDE;
bool atEnd() const Q_DECL_OVERRIDE;
bool flush();
bool flush(); // ### Qt6: remove me (implementation moved to private flush())
void abort();
// From QAbstractSocket:

View File

@ -191,6 +191,7 @@ public:
virtual qint64 peek(char *data, qint64 maxSize) Q_DECL_OVERRIDE;
virtual QByteArray peek(qint64 maxSize) Q_DECL_OVERRIDE;
bool flush() Q_DECL_OVERRIDE;
// Platform specific functions
virtual void startClientEncryption() = 0;