mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Divelogs.de: attempt to impletent 'Cancel' properly
The correct way to stop the upload/download is to use reply->abort(). If the dialog closes, post exec() we check if the reply 'isOpen' and abort and delete it. Without this modification the program seems to crash as the connection is still in action and it attempts to read an already deleted file. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
e0acad42aa
commit
04b62a46e9
1 changed files with 15 additions and 7 deletions
|
@ -327,9 +327,11 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
|
|||
}
|
||||
break;
|
||||
case QDialogButtonBox::RejectRole:
|
||||
// we may want to clean up after ourselves
|
||||
// reply->deleteLater();
|
||||
reply = NULL;
|
||||
if (reply != NULL && reply->isOpen()) {
|
||||
reply->abort();
|
||||
delete reply;
|
||||
reply = NULL;
|
||||
}
|
||||
resetState();
|
||||
break;
|
||||
case QDialogButtonBox::HelpRole:
|
||||
|
@ -569,10 +571,15 @@ void DivelogsDeWebServices::uploadDives(QIODevice *dldContent)
|
|||
|
||||
multipart = ∓
|
||||
hideDownload();
|
||||
resetState();
|
||||
exec();
|
||||
multipart = NULL;
|
||||
|
||||
delete reply; // we need to ensure it has stopped using our QHttpMultiPart
|
||||
multipart = NULL;
|
||||
if (reply != NULL && reply->isOpen()) {
|
||||
reply->abort();
|
||||
delete reply;
|
||||
reply = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
DivelogsDeWebServices::DivelogsDeWebServices(QWidget* parent, Qt::WindowFlags f): WebServices(parent, f)
|
||||
|
@ -755,6 +762,8 @@ void DivelogsDeWebServices::uploadFinished()
|
|||
// check what the server sent us: it might contain
|
||||
// an error condition, such as a failed login
|
||||
QByteArray xmlData = reply->readAll();
|
||||
reply->deleteLater();
|
||||
reply = NULL;
|
||||
char *resp = xmlData.data();
|
||||
if (resp) {
|
||||
char *parsed = strstr(resp, "<Login>");
|
||||
|
@ -782,7 +791,7 @@ void DivelogsDeWebServices::setStatusText(int status)
|
|||
void DivelogsDeWebServices::downloadError(QNetworkReply::NetworkError)
|
||||
{
|
||||
resetState();
|
||||
ui.status->setText(tr("Download error: %1").arg(reply->errorString()));
|
||||
ui.status->setText(tr("Error: %1").arg(reply->errorString()));
|
||||
reply->deleteLater();
|
||||
reply = NULL;
|
||||
}
|
||||
|
@ -820,7 +829,6 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
|
|||
case QDialogButtonBox::RejectRole:
|
||||
// these two seem to be causing a crash:
|
||||
// reply->deleteLater();
|
||||
// reply = NULL;
|
||||
resetState();
|
||||
break;
|
||||
case QDialogButtonBox::HelpRole:
|
||||
|
|
Loading…
Reference in a new issue