Qt-interest Archive, May 2008
QObject::sender() is NULL
Message 1 in thread
- Subject: QObject::sender() is NULL
- From: ÐÐÑÐÐ ÐÐÑÐÑÐÐÐ <uksus70@xxxxxxxxx>
- Date: Thu, 8 May 2008 13:50:46 +0800
- Delivered-to: qt-interest@trolltech.com
- Disposition-notification-to: ÐÐÑÐÐ ÐÐÑÐÑÐÐÐ <uksus70@gmail.com>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:return-receipt-to:from:to:subject:date:message-id:mime-version:content-type:x-mailer:thread-index:content-language:disposition-notification-to; bh=VRK8Dzy2Onfbp3oUk1w1u/CEtWm1GJKxcBnofb82bks=; b=CdofKQgE5fk79t/MEhWLSa0cm+deZTfZm1XkWju/ezB2+QD9GUZnloX0o+Wz6QyTYyoR9taBy22MsOD6tmHoyuBKfOLupifaELvCR9SXdCbjbQbGR7i6k8P31gNitmllcylQFAao1FhOt918maTaGDufaM6ka4Ie9P8/J++wMK4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=return-receipt-to:from:to:subject:date:message-id:mime-version:content-type:x-mailer:thread-index:content-language:disposition-notification-to; b=vymj1iSyyXQx2QBjPcid/qEpz9VlS/NrtYJGHseGzBPJv2cEr6CYKUu/L6a6tWm0MExpSFSvqSFAU4pmJ7j5x5jMn8n5je0KWkCNLCNw/+wjmSUErBe9qpQHnGqXfmcuSoi3XDgyccB+F2j/4jwsLL2rtUPGbSK1Gwe3z4O+2AY=
- List-help: <mailto:qt-interest-request@trolltech.com?subject=help>
- List-post: <mailto:qt-interest@trolltech.com>
- List-subscribe: <mailto:qt-interest-request@trolltech.com?subject=subscribe>
- List-unsubscribe: <mailto:qt-interest-request@trolltech.com?subject=unsubscribe>
- Resent-from: qt-interest@xxxxxxxxxxxxx
- Resent-message-id: <BTrAxB.A.CM.TTpIIB@esparsett>
- Resent-sender: qt-interest-request@xxxxxxxxxxxxx
- Thread-index: Aciwz3WJXFLq31KFQoSf97A9UATveg==
- To: <qt-interest@xxxxxxxxxxxxx>
I have my object, created within the main thread which has such a slot:
class ClientManager : public QObject
{
Q_OBJECT
â
public slots:
void unregisterServer();
Also, I have a QTcpSocket, created in another thread.
Within one of the methods of ClientManager I connect:
connect(socket, SIGNAL(disconnected()), this, SLOT(unregisterServer()));
void ClientManager::unregisterServer()
{
QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(sender());
And here sender() returns NULL. What can be the cause?
Method unregisterServer() is used only by this connect().
Message 2 in thread
- Subject: RE: QObject::sender() is NULL
- From: ÐÐÑÐÐ ÐÐÑÐÑÐÐÐ <uksus70@xxxxxxxxx>
- Date: Thu, 8 May 2008 15:38:41 +0800
- Delivered-to: qt-interest@trolltech.com
- Disposition-notification-to: ÐÐÑÐÐ ÐÐÑÐÑÐÐÐ <uksus70@gmail.com>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:return-receipt-to:from:to:references:in-reply-to:subject:date:message-id:mime-version:content-type:x-mailer:thread-index:content-language:disposition-notification-to; bh=bSfYbuBlLRv+NO5SaFkDsiRIg6jnvq7XiEU9hGubP+8=; b=OdJVZTodItaTH1GKd6skvJ6YwmhL9QnIH2bA6VB7QoyRFfssWvvbRZz8HkJuoaXXyo/YsG/IppJxxbnQWAAdze+B/BpysmGN46bsnPDYs7e7Id2UT7keXC3ecFUNDu3ZQoyhX/fGDDkoKbO2jd+AxDIrM4NbflU+wdHHm6pOIqo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=return-receipt-to:from:to:references:in-reply-to:subject:date:message-id:mime-version:content-type:x-mailer:thread-index:content-language:disposition-notification-to; b=FozAb33K1f/nuWU7MTCv9fu/cqmn/DJy7K8cHiDahhmMmwGi26tKxzMwt3g+FKnwzwNBCB+MmAn0IGBwXoB1i9FBgsv2pIs0BqRJIvt7f/f+NJz+lzDgobUUphegWbfetnqGsMK9oqFoTT2udDngP+vV5doU0WR2aVYs+0lK3OI=
- List-help: <mailto:qt-interest-request@trolltech.com?subject=help>
- List-post: <mailto:qt-interest@trolltech.com>
- List-subscribe: <mailto:qt-interest-request@trolltech.com?subject=subscribe>
- List-unsubscribe: <mailto:qt-interest-request@trolltech.com?subject=unsubscribe>
- Resent-from: qt-interest@xxxxxxxxxxxxx
- Resent-message-id: <lR9NV.A.9AH.f4qIIB@esparsett>
- Resent-sender: qt-interest-request@xxxxxxxxxxxxx
- Thread-index: Aciwz3WJXFLq31KFQoSf97A9UATvegAAiFRQ
- To: <qt-interest@xxxxxxxxxxxxx>
Iâve solved the problem myself.
When connecting two objects which belong to different threads, the default connection type is Qt::QueuedConnection. And probably the socket was deleted before the slot was triggered.
The solution is:
connect(socket, SIGNAL(disconnected()), this, SLOT(unregisterServer()), Qt::BlockingQueuedConnection);
This works well.
Message 3 in thread
Am Donnerstag, 8. Mai 2008 schrieb ÐÐÑÐÐ ÐÐÑÐÑÐÐÐ:
> Iâve solved the problem myself.
> When connecting two objects which belong to different threads, the default
> connection type is Qt::QueuedConnection. And probably the socket was
> deleted before the slot was triggered.
> The solution is:
> connect(socket, SIGNAL(disconnected()), this,
> SLOT(unregisterServer()), Qt::BlockingQueuedConnection);
> This works well.
But this actually removes all the benefits of using multiple threads. If you
want blocking behavior, you don't need threads...
Arnold
--
[ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.