Inside the ctor of the private data, the QObject has not yet
been associated with the data. Thus, accessing it indirectly i.e.
to setup private signal/slot connections, will trigger crashes.
Now we delay accessing this API and call an init() function manually
in the parent QObject-inheriting class.
Change-Id: I2c3ce7335c54d42af6bce87de867ee0ef197efc6
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
QObject *parent) :
QObject(*(new QWebSocketPrivate(origin, version, this)), parent)
{
+ Q_D(QWebSocket);
+ d->init();
}
/*!
QWebSocketProtocol::Version version, QObject *parent) :
QObject(*(new QWebSocketPrivate(pTcpSocket, version, this)), parent)
{
+ Q_D(QWebSocket);
+ d->init();
}
/*!
m_dataProcessor(),
m_configuration()
{
- init();
}
/*!
m_dataProcessor(),
m_configuration()
{
- init();
- makeConnections(m_pSocket.data());
}
/*!
Q_ASSERT(q_ptr);
//TODO: need a better randomizer
qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch()));
+
+ if (m_pSocket) {
+ makeConnections(m_pSocket.data());
+ }
}
/*!
#ifdef QT_NO_SSL
Q_UNUSED(secureMode)
#endif
+ Q_D(QWebSocketServer);
+ d->init();
}
/*!
m_errorString()
{
Q_ASSERT(pWebSocketServer);
+}
+
+/*!
+ \internal
+ */
+void QWebSocketServerPrivate::init()
+{
if (m_secureMode == NonSecureMode) {
m_pTcpServer = new QTcpServer();
if (Q_LIKELY(m_pTcpServer))
QWebSocketServer * const pWebSocketServer);
virtual ~QWebSocketServerPrivate();
+ void init();
void close();
QString errorString() const;
bool hasPendingConnections() const;