From f213a059fbad6cf64be51591b44f096a7f99596c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 May 2016 15:46:26 -0700 Subject: [PATCH] Fix AddressManager not always storing history when it should --- libraries/networking/src/AddressManager.cpp | 13 +++++++------ libraries/networking/src/AddressManager.h | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 3e359e5ddb..8e8ce9c4b0 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -310,7 +310,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const if (!returnedPath.isEmpty()) { if (shouldFaceViewpoint) { // try to parse this returned path as a viewpoint, that's the only thing it could be for now - if (!handleViewpoint(returnedPath, shouldFaceViewpoint)) { + if (!handleViewpoint(returnedPath, shouldFaceViewpoint, trigger)) { qCDebug(networking) << "Received a location path that was could not be handled as a viewpoint -" << returnedPath; } @@ -446,7 +446,7 @@ bool AddressManager::handleDomainID(const QString& host) { } void AddressManager::handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly) { - if (!handleViewpoint(path, false, wasPathOnly)) { + if (!handleViewpoint(path, false, trigger, wasPathOnly)) { qCDebug(networking) << "User entered path could not be handled as a viewpoint - " << path << "- wll attempt to ask domain-server to resolve."; @@ -463,7 +463,7 @@ void AddressManager::handlePath(const QString& path, LookupTrigger trigger, bool } } -bool AddressManager::handleViewpoint(const QString& viewpointString, bool shouldFace, +bool AddressManager::handleViewpoint(const QString& viewpointString, bool shouldFace, LookupTrigger trigger, bool definitelyPathOnly, const QString& pathString) { const QString FLOAT_REGEX_STRING = "([-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)"; const QString SPACED_COMMA_REGEX_STRING = "\\s*,\\s*"; @@ -491,8 +491,9 @@ bool AddressManager::handleViewpoint(const QString& viewpointString, bool should // before moving to a new host thanks to the information in the same lookup URL. - if (definitelyPathOnly || (!pathString.isEmpty() && pathString != _newHostLookupPath)) { - addCurrentAddressToHistory(LookupTrigger::UserInput); + if (definitelyPathOnly || (!pathString.isEmpty() && pathString != _newHostLookupPath) + || trigger == Back || trigger == Forward) { + addCurrentAddressToHistory(trigger); } if (!isNaN(newPosition.x) && !isNaN(newPosition.y) && !isNaN(newPosition.z)) { @@ -599,7 +600,7 @@ void AddressManager::copyPath() { void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) { // if we're cold starting and this is called for the first address (from settings) we don't do anything - if (trigger != LookupTrigger::StartupFromSettings) { + if (trigger != LookupTrigger::StartupFromSettings && trigger != LookupTrigger::DomainPathResponse) { if (trigger == LookupTrigger::Back) { // we're about to push to the forward stack // if it's currently empty emit our signal to say that going forward is now possible diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index c0ba69018c..9bc9bd679b 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -46,7 +46,8 @@ public: UserInput, Back, Forward, - StartupFromSettings + StartupFromSettings, + DomainPathResponse }; bool isConnected(); @@ -77,7 +78,7 @@ public slots: // we currently expect this to be called from NodeList once handleLookupString has been called with a path bool goToViewpointForPath(const QString& viewpointString, const QString& pathString) - { return handleViewpoint(viewpointString, false, false, pathString); } + { return handleViewpoint(viewpointString, false, DomainPathResponse, false, pathString); } void goBack(); void goForward(); @@ -125,7 +126,7 @@ private: bool handleNetworkAddress(const QString& lookupString, LookupTrigger trigger); void handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly = false); - bool handleViewpoint(const QString& viewpointString, bool shouldFace = false, + bool handleViewpoint(const QString& viewpointString, bool shouldFace, LookupTrigger trigger, bool definitelyPathOnly = false, const QString& pathString = QString()); bool handleUsername(const QString& lookupString); bool handleDomainID(const QString& host);