[Qt-interest] Using QSslSocket with QTcpServer results in segfault
Nikos Chantziaras
realnc at arcor.de
Sun Dec 6 09:31:49 CET 2009
On 12/06/2009 10:04 AM, Thiago Macieira wrote:
> Em Domingo 6. Dezembro 2009, às 08.50.54, Nikos Chantziaras escreveu:
>> The rest of the "Fortune Server" app stays the same. However, when
>> connecting to the server, the application crashes instantly with:
>>
>> QObject::connect: Cannot connect (null)::disconnected() to
>> (null)::deleteLater()
>> Segmentation fault
>>
>> What am I doing wrong?
>
> Nothing in your paste says either "disconnected" or "deleteLater". So it's not
> in the parts you pasted, but somewhere else.
>
> There, you're connecting a null pointer's signal to its slot. What happened
> next is anyone's guess (since you didn't paste it): mine is that you called
> something on that null pointer, which resulted in the crash.
You are right. It seems I made the wrong assumption that QSslSocket can
be used as a drop-in replacement for QTcpSocket like this:
QTcpSocket* socket = fTcpServer->nextPendingConnection();
connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
fTcpServer actually points to an SslServer object and in this case
nextPendingConnection() returns 0. I was trying to use polymorphism
here in order to leave that code alone. But I guess it's never that easy :P
More information about the Qt-interest-old
mailing list