forked from qt-creator/qt-creator
CodePaster: Do not leak the test reply, do not show empty message.
... on canceling.
This commit is contained in:
@@ -128,7 +128,8 @@ bool Protocol::ensureConfiguration(Protocol *p, QWidget *parent)
|
|||||||
ok = true;
|
ok = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!showConfigurationError(p, errorMessage, parent))
|
// Cancel returns empty error message.
|
||||||
|
if (errorMessage.isEmpty() || !showConfigurationError(p, errorMessage, parent))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
@@ -209,19 +210,20 @@ bool NetworkProtocol::httpStatus(QString url, QString *errorMessage)
|
|||||||
url.prepend(httpPrefix);
|
url.prepend(httpPrefix);
|
||||||
url.append(QLatin1Char('/'));
|
url.append(QLatin1Char('/'));
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = httpGet(url);
|
QScopedPointer<QNetworkReply> reply(httpGet(url));
|
||||||
QMessageBox box(QMessageBox::Information,
|
QMessageBox box(QMessageBox::Information,
|
||||||
tr("Checking connection"),
|
tr("Checking connection"),
|
||||||
tr("Connecting to %1...").arg(url),
|
tr("Connecting to %1...").arg(url),
|
||||||
QMessageBox::Cancel,
|
QMessageBox::Cancel,
|
||||||
Core::ICore::instance()->mainWindow());
|
Core::ICore::instance()->mainWindow());
|
||||||
connect(reply, SIGNAL(finished()), &box, SLOT(close()));
|
connect(reply.data(), SIGNAL(finished()), &box, SLOT(close()));
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
box.exec();
|
box.exec();
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
// User canceled, discard and be happy.
|
// User canceled, discard and be happy.
|
||||||
if (!reply->isFinished()) {
|
if (!reply->isFinished()) {
|
||||||
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
|
QNetworkReply *replyPtr = reply.take();
|
||||||
|
connect(replyPtr, SIGNAL(finished()), replyPtr, SLOT(deleteLater()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Passed
|
// Passed
|
||||||
|
Reference in New Issue
Block a user