Bug 1208814 - Part 2: Don't use the default copy constructor in nsNavHistoryQuery::Clone(), r=ehsan

This commit is contained in:
Michael Layzell 2015-09-29 12:31:34 -04:00
Родитель 977f9a33ea
Коммит be661c08ad
2 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -908,6 +908,19 @@ nsNavHistoryQuery::nsNavHistoryQuery()
mDomain.SetIsVoid(true);
}
nsNavHistoryQuery::nsNavHistoryQuery(const nsNavHistoryQuery& aOther)
: mMinVisits(aOther.mMinVisits), mMaxVisits(aOther.mMaxVisits),
mBeginTime(aOther.mBeginTime),
mBeginTimeReference(aOther.mBeginTimeReference),
mEndTime(aOther.mEndTime), mEndTimeReference(aOther.mEndTimeReference),
mSearchTerms(aOther.mSearchTerms), mOnlyBookmarked(aOther.mOnlyBookmarked),
mDomainIsHost(aOther.mDomainIsHost), mDomain(aOther.mDomain),
mUriIsPrefix(aOther.mUriIsPrefix), mUri(aOther.mUri),
mAnnotationIsNot(aOther.mAnnotationIsNot),
mAnnotation(aOther.mAnnotation), mTags(aOther.mTags),
mTagsAreNot(aOther.mTagsAreNot), mTransitions(aOther.mTransitions)
{}
NS_IMETHODIMP nsNavHistoryQuery::GetBeginTime(PRTime *aBeginTime)
{
*aBeginTime = mBeginTime;
@ -1321,11 +1334,10 @@ NS_IMETHODIMP nsNavHistoryQuery::Clone(nsINavHistoryQuery** _retval)
{
*_retval = nullptr;
nsNavHistoryQuery *clone = new nsNavHistoryQuery(*this);
nsRefPtr<nsNavHistoryQuery> clone = new nsNavHistoryQuery(*this);
NS_ENSURE_TRUE(clone, NS_ERROR_OUT_OF_MEMORY);
clone->mRefCnt = 0; // the clone doesn't inherit our refcount
NS_ADDREF(*_retval = clone);
clone.forget(_retval);
return NS_OK;
}

Просмотреть файл

@ -26,7 +26,7 @@ class nsNavHistoryQuery final : public nsINavHistoryQuery
{
public:
nsNavHistoryQuery();
// note: we use a copy constructor in Clone(), the default is good enough
nsNavHistoryQuery(const nsNavHistoryQuery& aOther);
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID)
NS_DECL_ISUPPORTS