diff --git a/content/base/src/Link.cpp b/content/base/src/Link.cpp index 8acd27b796b..10b77cbaf0a 100644 --- a/content/base/src/Link.cpp +++ b/content/base/src/Link.cpp @@ -58,6 +58,11 @@ Link::Link() { } +Link::~Link() +{ + UnregisterFromHistory(); +} + nsLinkState Link::GetLinkState() const { @@ -461,13 +466,11 @@ Link::UnregisterFromHistory() return; } - // Obtain the URI that we registered with. - nsCOMPtr hrefURI(GetURI()); - NS_ASSERTION(hrefURI, "mRegistered is true, but we have no URI?!"); + NS_ASSERTION(mCachedURI, "mRegistered is true, but we have no cached URI?!"); // And tell History to stop tracking us. IHistory *history = nsContentUtils::GetHistory(); - nsresult rv = history->UnregisterVisitedCallback(hrefURI, this); + nsresult rv = history->UnregisterVisitedCallback(mCachedURI, this); NS_ASSERTION(NS_SUCCEEDED(rv), "This should only fail if we misuse the API!"); if (NS_SUCCEEDED(rv)) { mRegistered = false; diff --git a/content/base/src/Link.h b/content/base/src/Link.h index c8d80fea0b2..0e2619e2e2a 100644 --- a/content/base/src/Link.h +++ b/content/base/src/Link.h @@ -93,6 +93,8 @@ protected: */ virtual void ResetLinkState(); + virtual ~Link(); + private: /** * Unregisters from History so this node no longer gets notifications about diff --git a/toolkit/components/places/tests/cpp/mock_Link.h b/toolkit/components/places/tests/cpp/mock_Link.h index aeed9f9eb43..e2f01ceceb9 100644 --- a/toolkit/components/places/tests/cpp/mock_Link.h +++ b/toolkit/components/places/tests/cpp/mock_Link.h @@ -94,6 +94,10 @@ Link::Link() { } +Link::~Link() +{ +} + nsLinkState Link::GetLinkState() const {