cutelyst / simple-mail

An SMTP library written in C++ for Qt. Allows applications to send emails (MIME with text, html, attachments, inline files, etc.) via SMTP. Supports SSL and SMTP authentication.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

compile error in Qt 5.15.1

hexabyte23 opened this issue · comments

I get compile error in sender.cpp & server.cpp

../rcs/thirdparty/simple-mail/src/sender.cpp:148:24: error: static_cast from 'QAbstractSocket::SocketError (QAbstractSocket::)() const' to 'void (QTcpSocket::)(QTcpSocket::SocketError)' is not allowed
connect(d->socket, static_cast<void(QTcpSocket::)(QTcpSocket::SocketError)>(&QTcpSocket::error),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rcs/thirdparty/simple-mail/src/server.cpp:237:24: error: static_cast from 'QAbstractSocket::SocketError (QAbstractSocket::
)() const' to 'void (QTcpSocket::)(QTcpSocket::SocketError)' is not allowed
q->connect(socket, static_cast<void(QTcpSocket::
)(QTcpSocket::SocketError)>(&QTcpSocket::error),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

which Qt version/compiler are you using?

duh 5.15, well that's odd I didn't try with that version but is should work afaik

I use last Qt version 5.15.1 with Clang last OS X 12.0 version.

Since 5.14.2, Qt is no more allowed to use static_cast<void(QTcpSocket::*)(QTcpSocket::SocketError)> in connect(), I try to replace by

    q->connect(socket, static_cast<void(QTcpSocket::*)(QTcpSocket::SocketError)>(&QTcpSocket::error),
               q, [=] (QAbstractSocket::SocketError error) {...}

by

    q->connect(socket, &QAbstractSocket::errorOccurred,
               q, [=] (QAbstractSocket::SocketError error) {...}

but I introduce an infinite loop when error occur by doing so... inner change in Qt seems larger

From Qt docs errorOccurred was introduced in 5.15, where do you get an infinite loop?

Sorry, I get infinite loop inside function sendMail() during call server->sendMail(message), only in Qt5.15.1 version

can you grab a backtrace?

Quite difficult now to get back my old code, you don't succeed to have same issue ?

I still don't have 5.15 installed, but did you managed to work around the issue? or are using an older Qt?

no, I found another way to send mail by using sendmail() unix command directly

   QProcess sendMail;
   sendMail.setStandardInputFile(file.fileName());
   sendMail.start("sendmail", QStringList() << "-t");
   sendMail.waitForFinished();

Pushed fix