зеркало из https://github.com/mozilla/pjs.git
Make ::Init() barf if the element is not a container, rather than sprinkling around in individual methods.
This commit is contained in:
Родитель
200dae8918
Коммит
b8f5dd60c9
|
@ -136,6 +136,23 @@ RDFContainerImpl::Init(nsIRDFDataSource *aDataSource, nsIRDFResource *aContainer
|
||||||
if (! aContainer)
|
if (! aContainer)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
PRBool isContainer;
|
||||||
|
rv = gRDFContainerUtils->IsContainer(aDataSource, aContainer, &isContainer);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (! isContainer) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
nsCAutoString msg;
|
||||||
|
nsXPIDLCString uri;
|
||||||
|
aContainer->GetValue(getter_Copies(uri));
|
||||||
|
msg += uri;
|
||||||
|
msg += " is not an RDF container";
|
||||||
|
NS_WARNING((const char*) msg);
|
||||||
|
#endif
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IF_RELEASE(mDataSource);
|
NS_IF_RELEASE(mDataSource);
|
||||||
mDataSource = aDataSource;
|
mDataSource = aDataSource;
|
||||||
NS_ADDREF(mDataSource);
|
NS_ADDREF(mDataSource);
|
||||||
|
@ -209,14 +226,6 @@ RDFContainerImpl::AppendElement(nsIRDFNode *aElement)
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
PRBool isContainer;
|
|
||||||
rv = gRDFContainerUtils->IsContainer(mDataSource, mContainer, &isContainer);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
NS_PRECONDITION(isContainer, "not a container");
|
|
||||||
if (! isContainer)
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIRDFResource> nextVal;
|
nsCOMPtr<nsIRDFResource> nextVal;
|
||||||
rv = GetNextValue(getter_AddRefs(nextVal));
|
rv = GetNextValue(getter_AddRefs(nextVal));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче