From 862ac1547c19b02fc36bdc4b6ce5c6cf3442a868 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Thu, 6 Feb 2014 17:42:05 +0100 Subject: [PATCH] Do not try to invoke/emit signal on shutdown. I'm actually not sure whether this is the right way to do this, but when the object is destroyed, we cannot delay the signal emit. In that case, we just don't emit it at all. This is the old behavior minus the warning: QWARN : tst_QWebSocketServer::tst_initialisation() QMetaObject::invokeMethod: No such method QObject::closed() Change-Id: I0513dd693ef7bfc43621e24361e72e90204fbea3 Reviewed-by: Kurt Pattyn --- src/websockets/qwebsocketserver_p.cpp | 12 +++++++----- src/websockets/qwebsocketserver_p.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index 6797cbc..f1c616d 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -111,14 +111,14 @@ void QWebSocketServerPrivate::init() */ QWebSocketServerPrivate::~QWebSocketServerPrivate() { - close(); + close(true); m_pTcpServer->deleteLater(); } /*! \internal */ -void QWebSocketServerPrivate::close() +void QWebSocketServerPrivate::close(bool aboutToDestroy) { Q_Q(QWebSocketServer); m_pTcpServer->close(); @@ -128,9 +128,11 @@ void QWebSocketServerPrivate::close() QWebSocketServer::tr("Server closed.")); pWebSocket->deleteLater(); } - //emit signal via the event queue, so the server gets time - //to process any hanging events, like flushing buffers aso - QMetaObject::invokeMethod(q, "closed", Qt::QueuedConnection); + if (!aboutToDestroy) { + //emit signal via the event queue, so the server gets time + //to process any hanging events, like flushing buffers aso + QMetaObject::invokeMethod(q, "closed", Qt::QueuedConnection); + } } /*! diff --git a/src/websockets/qwebsocketserver_p.h b/src/websockets/qwebsocketserver_p.h index c4afd3d..e932607 100644 --- a/src/websockets/qwebsocketserver_p.h +++ b/src/websockets/qwebsocketserver_p.h @@ -86,7 +86,7 @@ public: virtual ~QWebSocketServerPrivate(); void init(); - void close(); + void close(bool aboutToDestroy = false); QString errorString() const; bool hasPendingConnections() const; bool isListening() const; -- 2.7.4