Bug 13121. Deal with XUL documents that are created _before_ local store is available (e.g., because they come up before a profile has been selected).

This commit is contained in:
waterson%netscape.com 1999-09-14 22:36:55 +00:00
Родитель 3a2015c4e4
Коммит 57e13eb1a7
4 изменённых файлов: 53 добавлений и 57 удалений

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

@ -2058,14 +2058,15 @@ XULDocumentImpl::EndLoad()
// Add the local store to the composite datasource. It's first
// so that any local annotations will over-ride default values
// from the document.
// from the document. Note that we may not be able to get a
// local store if we don't yet have a profile.
rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(mLocalStore));
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create local data source");
if (NS_FAILED(rv)) return rv;
rv = db->AddDataSource(mLocalStore);
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't add local data source to db");
if (NS_FAILED(rv)) return rv;
if (NS_SUCCEEDED(rv)) {
rv = db->AddDataSource(mLocalStore);
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't add local data source to db");
if (NS_FAILED(rv)) return rv;
}
// Add the main document datasource to the content model builder
rv = db->AddDataSource(mDocumentDataSource);
@ -3160,6 +3161,12 @@ XULDocumentImpl::Persist(const nsString& aID, const nsString& aAttr)
nsresult
XULDocumentImpl::Persist(nsIContent* aElement, PRInt32 aNameSpaceID, nsIAtom* aAttribute)
{
// First make sure we _have_ a local store to stuff the persited
// information into. (We might not have one if profile information
// hasn't been loaded yet...)
if (! mLocalStore)
return NS_OK;
nsresult rv;
nsCOMPtr<nsIRDFResource> source;

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

@ -1397,13 +1397,12 @@ RDFXULBuilderImpl::CreateTemplateBuilder(nsIContent* aElement,
return rv;
}
// Add the local store as the first data source in the db.
{
nsCOMPtr<nsIRDFDataSource> localstore;
rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(localstore));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get local store");
if (NS_FAILED(rv)) return rv;
// Add the local store as the first data source in the db. Note
// that we _might_ not be able to get a local store if we haven't
// got a profile to read from yet.
nsCOMPtr<nsIRDFDataSource> localstore;
rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(localstore));
if (NS_SUCCEEDED(rv)) {
rv = db->AddDataSource(localstore);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add local store to db");
if (NS_FAILED(rv)) return rv;

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

@ -2058,14 +2058,15 @@ XULDocumentImpl::EndLoad()
// Add the local store to the composite datasource. It's first
// so that any local annotations will over-ride default values
// from the document.
// from the document. Note that we may not be able to get a
// local store if we don't yet have a profile.
rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(mLocalStore));
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create local data source");
if (NS_FAILED(rv)) return rv;
rv = db->AddDataSource(mLocalStore);
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't add local data source to db");
if (NS_FAILED(rv)) return rv;
if (NS_SUCCEEDED(rv)) {
rv = db->AddDataSource(mLocalStore);
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't add local data source to db");
if (NS_FAILED(rv)) return rv;
}
// Add the main document datasource to the content model builder
rv = db->AddDataSource(mDocumentDataSource);
@ -3160,6 +3161,12 @@ XULDocumentImpl::Persist(const nsString& aID, const nsString& aAttr)
nsresult
XULDocumentImpl::Persist(nsIContent* aElement, PRInt32 aNameSpaceID, nsIAtom* aAttribute)
{
// First make sure we _have_ a local store to stuff the persited
// information into. (We might not have one if profile information
// hasn't been loaded yet...)
if (! mLocalStore)
return NS_OK;
nsresult rv;
nsCOMPtr<nsIRDFResource> source;

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

@ -285,25 +285,23 @@ LocalStoreImpl::Init(const char *uri)
nsresult
LocalStoreImpl::Flush()
{
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
nsresult rv = NS_OK;
if (remote)
{
rv = remote->Flush();
}
return(rv);
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
NS_ASSERTION(remote != nsnull, "not an nsIRDFRemoteDataSource");
if (! remote)
return NS_ERROR_UNEXPECTED;
return remote->Flush();
}
nsresult
LocalStoreImpl::Refresh(PRBool sync)
{
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
nsresult rv = NS_OK;
if (remote)
{
rv = remote->Refresh(sync);
}
return NS_OK; // XXX Always return OK, even if we couldn't load the file.
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
NS_ASSERTION(remote != nsnull, "not an nsIRDFRemoteDataSource");
if (! remote)
return NS_ERROR_UNEXPECTED;
return remote->Refresh(sync);
}
nsresult
@ -315,24 +313,13 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsresult rv;
// Look for localstore.rdf in the current profile
// directory. This is as convoluted as it seems because we
// want to 1) not break viewer (which has no profiles), and 2)
// still deal reasonably (in the short term) when no
// localstore.rdf is installed in the profile directory.
// directory. Bomb if we can't find it.
NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);
if (NS_FAILED(rv)) return rv;
nsFileSpec spec;
do {
NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);
if (NS_FAILED(rv)) break;
rv = profile->GetCurrentProfileDir(&spec);
if (NS_FAILED(rv)) break;
} while (0);
if (NS_FAILED(rv)) {
// XXX We should probably tell the user that we're doing this.
spec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory);
}
nsFileSpec spec;
rv = profile->GetCurrentProfileDir(&spec);
if (NS_FAILED(rv)) return rv;
spec += "localstore.rdf";
@ -358,18 +345,14 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
if (NS_FAILED(rv)) return rv;
// register this as a named data source with the RDF service
nsIRDFService* rdf;
rv = nsServiceManager::GetService(kRDFServiceCID,
nsIRDFService::GetIID(),
(nsISupports**) &rdf);
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = rdf->RegisterDataSource(this, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register local store");
if (NS_FAILED(rv)) return rv;
nsServiceManager::ReleaseService(kRDFServiceCID, rdf);
return rv;
return NS_OK;
}