From: Soren Stoutner Date: Fri, 22 Mar 2024 20:31:39 +0000 (-0700) Subject: Fix HTTP authentication dialogs displaying indefinitely. https://redmine.stoutner... X-Git-Tag: v0.6~7 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=ce90749b5fc2c4a3fcee6daee60c0d6e2aa0e1d6;p=PrivacyBrowserPC.git Fix HTTP authentication dialogs displaying indefinitely. https://redmine.stoutner.com/issues/1180 --- diff --git a/src/widgets/PrivacyWebEngineView.cpp b/src/widgets/PrivacyWebEngineView.cpp index 6080288..42c331f 100644 --- a/src/widgets/PrivacyWebEngineView.cpp +++ b/src/widgets/PrivacyWebEngineView.cpp @@ -221,6 +221,9 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo if (reloadWebsite) reload(); + // Reset the HTTP authentication dialog counter. + httpAuthenticationDialogsDisplayed = 0; + // Update the UI. emit updateUi(this); } @@ -305,11 +308,17 @@ void PrivacyWebEngineView::displayHttpPingDialog(const QString &httpPingUrl) con void PrivacyWebEngineView::handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer) { - // Instantiate an HTTP authentication dialog. - HttpAuthenticationDialog *httpAuthenticationDialogPointer = new HttpAuthenticationDialog(parentWidget(), requestUrl, authenticatorPointer); + // Only display the HTTP authentication dialog if it hasn't already been displayed three times for this URL. + if (httpAuthenticationDialogsDisplayed < 3) { + // Increment the HTTP authentication dialog display counter. + ++httpAuthenticationDialogsDisplayed; + + // Instantiate an HTTP authentication dialog. + HttpAuthenticationDialog *httpAuthenticationDialogPointer = new HttpAuthenticationDialog(parentWidget(), requestUrl, authenticatorPointer); - // Display the dialog. This must be `exec()` instead of `show()` so that the website doesn't proceed before populating the authentication pointer. - httpAuthenticationDialogPointer->exec(); + // Display the dialog. This must be `exec()` instead of `show()` so that the website doesn't proceed before populating the authentication pointer. + httpAuthenticationDialogPointer->exec(); + } } void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const diff --git a/src/widgets/PrivacyWebEngineView.h b/src/widgets/PrivacyWebEngineView.h index 4f621ce..95cc69f 100644 --- a/src/widgets/PrivacyWebEngineView.h +++ b/src/widgets/PrivacyWebEngineView.h @@ -46,6 +46,7 @@ public: bool findCaseSensitive = false; QString findString = QLatin1String(""); QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult(); + int httpAuthenticationDialogsDisplayed = 0; bool isLoading = false; int loadProgressInt = -1; bool localStorageEnabled = false; diff --git a/src/widgets/TabWidget.cpp b/src/widgets/TabWidget.cpp index bdc541c..f65c79e 100644 --- a/src/widgets/TabWidget.cpp +++ b/src/widgets/TabWidget.cpp @@ -906,6 +906,9 @@ void TabWidget::printWebpage(QPrinter *printerPointer) const void TabWidget::refresh() const { + // Reset the HTTP authentication dialog counter. + currentPrivacyWebEngineViewPointer->httpAuthenticationDialogsDisplayed = 0; + // Reload the website. currentPrivacyWebEngineViewPointer->reload(); }