aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-17 10:22:08 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-17 10:22:08 +0200
commit0b86b204209d78f496721ac14ed33691d2c5db1e (patch)
treeb17f1cddc3820d260dda4d450c7b71c7dbd503ac /src
parent5b14fc424462a5d3a5a509bd177c04e9cba2ce17 (diff)
downloadkristall-0b86b204209d78f496721ac14ed33691d2c5db1e.tar.gz
Makes cancelling gemini requests more robust.
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp6
-rw-r--r--src/geminiclient.cpp12
2 files changed, 13 insertions, 5 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp
index 09bb56c..359fd7c 100644
--- a/src/browsertab.cpp
+++ b/src/browsertab.cpp
@@ -570,8 +570,10 @@ void BrowserTab::updateUI()
this->ui->back_button->setEnabled(history.oneBackward(current_history_index).isValid());
this->ui->forward_button->setEnabled(history.oneForward(current_history_index).isValid());
- this->ui->refresh_button->setVisible(this->successfully_loaded);
- this->ui->stop_button->setVisible(not this->successfully_loaded);
+ bool in_progress = (this->current_handler != nullptr) and this->current_handler->isInProgress();
+
+ this->ui->refresh_button->setVisible(not in_progress);
+ this->ui->stop_button->setVisible(in_progress);
this->ui->fav_button->setEnabled(this->successfully_loaded);
this->ui->fav_button->setChecked(global_favourites.contains(this->current_location));
diff --git a/src/geminiclient.cpp b/src/geminiclient.cpp
index 80f5742..afae454 100644
--- a/src/geminiclient.cpp
+++ b/src/geminiclient.cpp
@@ -36,6 +36,8 @@ bool GeminiClient::startRequest(const QUrl &url)
if(url.scheme() != "gemini")
return false;
+ // qDebug() << "start request" << url;
+
if(socket.state() != QTcpSocket::UnconnectedState) {
socket.disconnectFromHost();
socket.close();
@@ -73,14 +75,18 @@ bool GeminiClient::isInProgress() const
bool GeminiClient::cancelRequest()
{
+ // qDebug() << "cancel request" << isInProgress();
if(isInProgress())
{
this->is_receiving_body = false;
this->socket.disconnectFromHost();
- this->socket.close();
this->buffer.clear();
this->body.clear();
- return this->socket.waitForDisconnected(250);
+ this->socket.waitForDisconnected(500);
+ this->socket.close();
+ bool success = not isInProgress();
+ // qDebug() << "cancel success" << success;
+ return success;
}
else
{
@@ -103,7 +109,7 @@ void GeminiClient::disableClientCertificate()
void GeminiClient::socketEncrypted()
{
- qDebug() << "Pub key =" << socket.peerCertificate().publicKey().toPem();
+ // qDebug() << "Pub key =" << socket.peerCertificate().publicKey().toPem();
QString request = target_url.toString(QUrl::FormattingOptions(QUrl::FullyEncoded)) + "\r\n";