qa: Resolve Qt deprecation warnings - use sslHandshakeErrors
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 12 Mar 2021 14:25:34 +0000 (15:25 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 20 Mar 2021 14:55:17 +0000 (15:55 +0100)
Qt 5.15 introduced a new and improved signal name for accessing SSL
handshake errors, and at the same time started issuing a deprecation
warning for the old one, so we need some ifdefs for clean compilation.

src/client/clientauthhandler.cpp
src/qtui/mainwin.cpp
src/qtui/sslinfodlg.cpp

index 260128b..083b2dd 100644 (file)
@@ -410,7 +410,11 @@ void ClientAuthHandler::onSslSocketEncrypted()
     auto* socket = qobject_cast<QSslSocket*>(sender());
     Q_ASSERT(socket);
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
     if (!socket->sslErrors().count()) {
+#else
+    if (!socket->sslHandshakeErrors().count()) {
+#endif
         // Cert is valid, so we don't want to store it as known
         // That way, a warning will appear in case it becomes invalid at some point
         CoreAccountSettings s;
index 84246b8..acfe79f 100644 (file)
@@ -1384,8 +1384,14 @@ void MainWin::handleNoSslInCore(bool* accepted)
 void MainWin::handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently)
 {
     QString errorString = "<ul>";
-    foreach (const QSslError error, socket->sslErrors())
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+    for (const auto& error : socket->sslErrors()) {
+#else
+    for (const auto& error : socket->sslHandshakeErrors()) {
+#endif
         errorString += QString("<li>%1</li>").arg(error.errorString());
+    }
     errorString += "</ul>";
 
     QMessageBox box(QMessageBox::Warning,
index d1b845e..67f0dd5 100644 (file)
@@ -67,12 +67,19 @@ void SslInfoDlg::setCurrentCert(int index)
     ui.issuerState->setText(issuerInfo(cert, QSslCertificate::StateOrProvinceName));
     ui.issuerCity->setText(issuerInfo(cert, QSslCertificate::LocalityName));
 
-    if (socket()->sslErrors().isEmpty())
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+    const auto& sslErrors = socket()->sslErrors();
+#else
+    const auto& sslErrors = socket()->sslHandshakeErrors();
+#endif
+    if (sslErrors.isEmpty()) {
         ui.trusted->setText(tr("Yes"));
+    }
     else {
         QString errorString = tr("No, for the following reasons:<ul>");
-        foreach (const QSslError& error, socket()->sslErrors())
+        for (const auto& error : sslErrors) {
             errorString += "<li>" + error.errorString() + "</li>";
+        }
         errorString += "</ul>";
         ui.trusted->setText(errorString);
     }