summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/subsurfacewebservices.cpp16
-rw-r--r--qt-ui/subsurfacewebservices.h3
2 files changed, 10 insertions, 9 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 5edc5cb02..4713ef2af 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -23,7 +23,6 @@ WebServices::WebServices(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f)
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
connect(ui.download, SIGNAL(clicked(bool)), this, SLOT(startDownload()));
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
-
}
void WebServices::hidePassword()
@@ -37,6 +36,12 @@ void WebServices::hideUpload()
ui.upload->hide();
}
+QNetworkAccessManager *WebServices::manager()
+{
+ static QNetworkAccessManager *manager = new QNetworkAccessManager(qApp);
+ return manager;
+}
+
// #
// #
// # Subsurface Web Service Implementation.
@@ -89,9 +94,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
}
break;
case QDialogButtonBox::RejectRole:
- // we may want to clean up after ourselves, but this
- // makes Subsurface throw a SIGSEGV...
- // manager->deleteLater();
+ // we may want to clean up after ourselves
// reply->deleteLater();
ui.progressBar->setMaximum(1);
break;
@@ -108,11 +111,10 @@ void SubsurfaceWebServices::startDownload()
QUrl url("http://api.hohndel.org/api/dive/get/");
url.addQueryItem("login", ui.userID->text().toUpper());
- manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(url);
request.setRawHeader("Accept", "text/xml");
- reply = manager->get(request);
+ reply = manager()->get(request);
ui.status->setText(tr("Wait a bit until we have something..."));
ui.progressBar->setRange(0,0); // this makes the progressbar do an 'infinite spin'
ui.download->setEnabled(false);
@@ -136,7 +138,6 @@ void SubsurfaceWebServices::downloadFinished()
if (resultCode == DD_STATUS_OK){
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
}
- manager->deleteLater();
reply->deleteLater();
}
@@ -145,7 +146,6 @@ void SubsurfaceWebServices::downloadError(QNetworkReply::NetworkError)
ui.download->setEnabled(true);
ui.progressBar->setRange(0,1);
ui.status->setText(QString::number((int)QNetworkRequest::HttpStatusCodeAttribute));
- manager->deleteLater();
reply->deleteLater();
}
diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h
index 83aba372b..0400fd503 100644
--- a/qt-ui/subsurfacewebservices.h
+++ b/qt-ui/subsurfacewebservices.h
@@ -17,6 +17,8 @@ public:
void hidePassword();
void hideUpload();
+ static QNetworkAccessManager *manager();
+
private slots:
virtual void startDownload() = 0;
virtual void startUpload() = 0;
@@ -25,7 +27,6 @@ private slots:
protected:
Ui::WebServices ui;
QNetworkReply *reply;
- QNetworkAccessManager *manager;
QByteArray downloadedData;
};