I'm developping an XPCOM component for firefox.
In my component, when I try to get the path and the prePath of the url
of the current page, firefox crashs ....
Code:
OnStateChange(nsIWebProgress* aWebProgress, nsIRequest*
aRequest,PRUint32 aStateFlags, nsresult aStatus)
{
[....]
nsCOMPtr<nsIDOMWindow> domWin;
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocument> domDoc;
domWin->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc); //
the htmlDoc is valid
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCAutoString prePath, path;
doc->GetDocumentURI()->GetPrePath(prePath); //here firefox crash he
can't get the prePath
doc->GetDocumentURI()->GetPath(path);
[....]
}
It seems firefox can't get the nsIDocument from the nsIDOMDocument and
so when he attempts to get the path on the execution, he crashs..
Code:
/usr/bin/firefox: line 159: Segmentation fault $AOSS $MOZ_PROGRAM $@
I'm on Suse 10.1 installed on a VMware, but this component ( and this
code) works fine on Window .....
Anybody have clues or ideas for solve my problem ... ?
> doc->GetDocumentURI()->GetPrePath(prePath); //here firefox crash he
Most probably, the document uri will be null:
/**
* Return the URI for the document. May return null.
*/
nsIURI* GetDocumentURI() const
michal
In addition, this is a basic code, that's why, i don't understand, why
this code isn't effective on linux !
Do you get a non-null "doc"?
> doc->GetDocumentURI()->GetPrePath(prePath); //here firefox crash he
Which exact version of nsIDocument.h are you compiling against? Which exact
version of Firefox are you running against?
-Boris
Ok Boris :
- No, I get a null "doc", but I get a valid (non-null) "htmlDoc" ....
strange !
- I'm running with the 1.5.0.3 version of firefox. This is the version
automatically installed with GNOME ( on Suse )
- I get the source from the CVS server with the appropriate commands
describes here :
http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS !
So I think I have the last version of nsIDocument.h.
But if you want to see the file :
http://membres.lycos.fr/gailin24px/ff/nsIDocument.h
Thx !
Not at all, given the version skew.
> - I'm running with the 1.5.0.3 version of firefox. This is the version
> automatically installed with GNOME ( on Suse )
OK. So that's
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/content/base/public/nsIDocument.h&rev=MOZILLA_1_8_0_3_RELEASE
-- note the value of NS_IDOCUMENT_IID.
> - I get the source from the CVS server with the appropriate commands
> describes here :
> http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS !
Using the branch tag that matches your Firefox version?
> So I think I have the last version of nsIDocument.h.
Which is not compatible with Gecko 1.8.0.3.
> But if you want to see the file :
> http://membres.lycos.fr/gailin24px/ff/nsIDocument.h
Yes, that's the current trunk version. Notice the different value of
NS_IDOCUMENT_IID.
Sounds like things are working correctly -- you're asking a branch Firefox for a
trunk nsIDocument, and it doesn't have one. So it returns null.
I suggest developing against headers that match the branch you want to work with.
-Boris
thx a lot boris ;)