mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Bug 1598915 - [1/2] Drive-by cleanup: replace manual pointer-fiddling with RefPtr r=win-reviewers,handyman
`nsDataObj::mTransferable`'s lifecycle and ownership semantics are trivially that of `RefPtr`. Use it. (We do not presently extend this to `m_enumFE`, below; according to comments in IEnumFE.h, that one's less trivial.) No functional changes. Differential Revision: https://phabricator.services.mozilla.com/D216624
This commit is contained in:
parent
c9db119981
commit
93c15cc946
@ -530,7 +530,7 @@ nsDataObj::nsDataObj(nsIURI* uri)
|
||||
// destruction
|
||||
//-----------------------------------------------------
|
||||
nsDataObj::~nsDataObj() {
|
||||
NS_IF_RELEASE(mTransferable);
|
||||
mTransferable = nullptr;
|
||||
|
||||
mDataFlavors.Clear();
|
||||
|
||||
@ -774,7 +774,7 @@ STDMETHODIMP nsDataObj::GetData(LPFORMATETC aFormat, LPSTGMEDIUM pSTM) {
|
||||
// ("***** nsDataObj::GetData - Unknown format %u\n", format));
|
||||
return GetText(df, *aFormat, *pSTM);
|
||||
} // switch
|
||||
} // if
|
||||
} // if
|
||||
dfInx++;
|
||||
} // while
|
||||
|
||||
@ -1861,16 +1861,7 @@ void nsDataObj::AddDataFlavor(const char* aDataFlavor, LPFORMATETC aFE) {
|
||||
// Sets the transferable object
|
||||
//-----------------------------------------------------
|
||||
void nsDataObj::SetTransferable(nsITransferable* aTransferable) {
|
||||
NS_IF_RELEASE(mTransferable);
|
||||
|
||||
mTransferable = aTransferable;
|
||||
if (nullptr == mTransferable) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ADDREF(mTransferable);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -166,9 +166,8 @@ class nsDataObj : public IDataObject, public IDataObjectAsyncCapability {
|
||||
private:
|
||||
nsTArray<nsCString> mDataFlavors;
|
||||
|
||||
nsITransferable* mTransferable; // nsDataObj owns and ref counts
|
||||
// nsITransferable, the nsITransferable does
|
||||
// know anything about the nsDataObj
|
||||
// the nsITransferable knows nothing about the nsDataObj
|
||||
RefPtr<nsITransferable> mTransferable;
|
||||
|
||||
protected:
|
||||
CEnumFormatEtc* m_enumFE; // Ownership Rules:
|
||||
|
Loading…
Reference in New Issue
Block a user