Return an already-addrefed nsTreeColumn instead of making assumptions about

object lifetimes.  Bug 309429 followup, patch by Nickolay Ponomarev
<asqueella@gmail.com>, r+sr=neil
This commit is contained in:
bzbarsky%mit.edu 2007-01-08 02:41:05 +00:00
parent 88a4bed601
commit f31edc79b8
2 changed files with 10 additions and 11 deletions

View File

@ -621,7 +621,7 @@ nsTreeBodyFrame::InvalidateColumn(nsITreeColumn* aCol)
if (mUpdateBatchNest)
return NS_OK;
nsTreeColumn* col = GetColumnImpl(aCol);
nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
@ -666,7 +666,7 @@ nsTreeBodyFrame::InvalidateCell(PRInt32 aIndex, nsITreeColumn* aCol)
if (aIndex < 0 || aIndex > mPageLength)
return NS_OK;
nsTreeColumn* col = GetColumnImpl(aCol);
nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
@ -709,7 +709,7 @@ nsTreeBodyFrame::InvalidateColumnRange(PRInt32 aStart, PRInt32 aEnd, nsITreeColu
if (mUpdateBatchNest)
return NS_OK;
nsTreeColumn* col = GetColumnImpl(aCol);
nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
@ -1630,7 +1630,7 @@ nsTreeBodyFrame::IsCellCropped(PRInt32 aRow, nsITreeColumn* aCol, PRBool *_retva
nsCOMPtr<nsIRenderingContext> rc;
GetPresContext()->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
nsTreeColumn* col = GetColumnImpl(aCol);
nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
@ -3645,7 +3645,7 @@ nsresult nsTreeBodyFrame::EnsureRowIsVisibleInternal(const ScrollParts& aParts,
NS_IMETHODIMP nsTreeBodyFrame::EnsureCellIsVisible(PRInt32 aRow, nsITreeColumn* aCol)
{
nsTreeColumn* col = GetColumnImpl(aCol);
nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
@ -3690,7 +3690,7 @@ NS_IMETHODIMP nsTreeBodyFrame::ScrollToColumn(nsITreeColumn* aCol)
nsresult nsTreeBodyFrame::ScrollToColumnInternal(const ScrollParts& aParts,
nsITreeColumn* aCol)
{
nsTreeColumn* col = GetColumnImpl(aCol);
nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
if (!col)
return NS_ERROR_INVALID_ARG;
return ScrollHorzInternal(aParts, col->GetX());

View File

@ -356,14 +356,13 @@ protected:
InvalidateRow(aRow + aOrientation);
};
nsTreeColumn* GetColumnImpl(nsITreeColumn* aUnknownCol) {
already_AddRefed<nsTreeColumn> GetColumnImpl(nsITreeColumn* aUnknownCol) {
if (!aUnknownCol)
return nsnull;
nsRefPtr<nsTreeColumn> col;
nsresult rv = aUnknownCol->QueryInterface(kTreeColumnImplCID,
getter_AddRefs(col));
return NS_SUCCEEDED(rv) ? col.get() : nsnull;
nsTreeColumn* col;
aUnknownCol->QueryInterface(kTreeColumnImplCID, (void**)&col);
return col;
}
// Create a new timer. This method is used to delay various actions like