From ce46bb4dfe22263544e41e752208cdb6bd0b6ed5 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Sun, 6 Feb 2011 16:16:27 -0500 Subject: [PATCH 03/23] Change the AutoFillManager to not use hard coded offsets for request attributes. Rather than a offset from the QNetworkRequest::User utilize the static WebPageProxy::pageAttributeId() to improve the code readability (it is now grepable what it is used for) and prevent accidents in the future if that number ever changed. --- src/autofillmanager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git src/autofillmanager.cpp src/autofillmanager.cpp index b39e747..8c4891d 100644 --- src/autofillmanager.cpp +++ src/autofillmanager.cpp @@ -32,6 +32,7 @@ #include "browserapplication.h" #include "browsermainwindow.h" #include "networkaccessmanagerproxy.h" +#include "webpageproxy.h" #include "webview.h" #include @@ -145,7 +146,7 @@ void AutoFillManager::post(const QNetworkRequest &request, const QByteArray &out return; // Check the request type - QVariant typeVariant = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 101)); + QVariant typeVariant = request.attribute((QNetworkRequest::Attribute)(WebPageProxy::pageAttributeId() + 1)); QWebPage::NavigationType type = (QWebPage::NavigationType)typeVariant.toInt(); if (typeVariant.isValid() && type != QWebPage::NavigationTypeFormSubmitted) { // XXX Does this occur normally? @@ -155,7 +156,7 @@ void AutoFillManager::post(const QNetworkRequest &request, const QByteArray &out } // Determine the QWebView - QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100)); + QVariant v = request.attribute((QNetworkRequest::Attribute)(WebPageProxy::pageAttributeId())); QWebPage *webPage = (QWebPage*)(v.value()); if (!webPage) { qWarning() << "AutoFillManager:" << "QWebPage is not set in QNetworkRequest."; -- 2.44.0